Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
});
})
});
});