Skip to content

Commit

Permalink
Use Wazo.Auth.mobile to send samlLogin mobile header
Browse files Browse the repository at this point in the history
  • Loading branch information
manuquentin committed Jul 18, 2024
1 parent b718084 commit c34fbf1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/__tests__/api-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface AuthD {
authenticate: (token: Token) => Promise<Session | null | undefined>;
logIn(params: LoginParams): Promise<Session | null | undefined> ;
logOut: (token: Token) => Promise<LogoutResponse>;
samlLogIn: (samlSessionId: string, options? : { mobile?: boolean }) => Promise<Session | null | undefined>;
samlLogIn: (samlSessionId: string) => Promise<Session | null | undefined>;
initiateIdpAuthentication(domain: string, redirectUrl: string): Promise<any>;
refreshToken: (refreshToken: string, backend: string, expiration: number, isMobile?: boolean, tenantId?: string, domainName?: string) => Promise<Session | null | undefined>;
deleteRefreshToken: (clientId: string) => Promise<boolean>;
Expand Down Expand Up @@ -117,7 +117,7 @@ export default ((client: ApiRequester, baseUrl: string): AuthD => ({

logOut: (token: Token): Promise<LogoutResponse> => client.delete(`${baseUrl}/token/${token}`, null, {}, ApiRequester.successResponseParser),

samlLogIn: async (samlSessionId: string, options : { mobile?: boolean } = {}): Promise<Session | null | undefined> => {
samlLogIn: async (samlSessionId: string): Promise<Session | null | undefined> => {
const headers: Record<string, any> = {
Accept: 'application/json',
'Content-Type': 'application/json',
Expand All @@ -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';
}

Expand Down

0 comments on commit c34fbf1

Please sign in to comment.