From c34fbf1d17bfaa2172ccc2498acb8db5468b0bc9 Mon Sep 17 00:00:00 2001 From: Emmanuel Quentin Date: Thu, 18 Jul 2024 09:44:48 -0400 Subject: [PATCH] Use Wazo.Auth.mobile to send samlLogin mobile header --- src/__tests__/api-client.test.ts | 3 ++- src/api/auth.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/__tests__/api-client.test.ts b/src/__tests__/api-client.test.ts index efea1633..2b49122b 100644 --- a/src/__tests__/api-client.test.ts +++ b/src/__tests__/api-client.test.ts @@ -141,8 +141,9 @@ describe('With correct API results', () => { describe('samlLogIn mobile test', () => { it('should retrieve user token', async () => { + Wazo.Auth.mobile = true; const samlSessionId = 'a1b2C3d4'; - const result = await client.auth.samlLogIn(samlSessionId, { mobile: true }); + const result = await client.auth.samlLogIn(samlSessionId); expect(result).toBeInstanceOf(Session); expect(result?.token).toBe(1); diff --git a/src/api/auth.ts b/src/api/auth.ts index 41075f0f..1a7e630e 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -32,7 +32,7 @@ export interface AuthD { authenticate: (token: Token) => Promise; logIn(params: LoginParams): Promise ; logOut: (token: Token) => Promise; - samlLogIn: (samlSessionId: string, options? : { mobile?: boolean }) => Promise; + samlLogIn: (samlSessionId: string) => Promise; initiateIdpAuthentication(domain: string, redirectUrl: string): Promise; refreshToken: (refreshToken: string, backend: string, expiration: number, isMobile?: boolean, tenantId?: string, domainName?: string) => Promise; deleteRefreshToken: (clientId: string) => Promise; @@ -117,7 +117,7 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({ logOut: (token: Token): Promise => client.delete(`${baseUrl}/token/${token}`, null, {}, ApiRequester.successResponseParser), - samlLogIn: async (samlSessionId: string, options : { mobile?: boolean } = {}): Promise => { + samlLogIn: async (samlSessionId: string): Promise => { const headers: Record = { Accept: 'application/json', 'Content-Type': 'application/json', @@ -132,7 +132,7 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({ body.client_id = client.clientId; } - if (options.mobile) { + if (Wazo.Auth.mobile) { headers['Wazo-Session-Type'] = 'mobile'; }