Skip to content

Commit

Permalink
fix(authentication-client): Allow reAuthentication using specific str…
Browse files Browse the repository at this point in the history
…ategy (#2140)
  • Loading branch information
deskoh committed Dec 5, 2020
1 parent ef1398c commit 2a2bbf7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/authentication-client/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class AuthenticationClient {
return Promise.reject(error);
}

reAuthenticate (force: boolean = false): Promise<AuthenticationResult> {
reAuthenticate (force: boolean = false, strategy?: string): Promise<AuthenticationResult> {
// Either returns the authentication state or
// tries to re-authenticate with the stored JWT and strategy
const authPromise = this.app.get('authentication');
Expand All @@ -144,7 +144,7 @@ export class AuthenticationClient {
}

return this.authenticate({
strategy: this.options.jwtStrategy,
strategy: strategy || this.options.jwtStrategy,
accessToken
});
});
Expand Down
22 changes: 22 additions & 0 deletions packages/authentication-client/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,27 @@ describe('@feathersjs/authentication-client', () => {
assert.ok(!app.get('authentication'));
});
});

it('reauthenticates using different strategy', async () => {
app.configure(client({ jwtStrategy: 'any' }));

const data = {
strategy: 'testing'
};

let result = await app.authenticate(data);
assert.deepStrictEqual(result, {
accessToken,
data,
user
});

result = await app.authentication.reAuthenticate(false, 'jwt');
assert.deepStrictEqual(result, {
accessToken,
data,
user
});
})
});
});

0 comments on commit 2a2bbf7

Please sign in to comment.