Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(authentication-client): Allow to abort fetch #3310

Merged
merged 2 commits into from
Nov 27, 2023
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 docs/api/client/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ const controller = new AbortController()

app.configure(restClient.fetch(fetch))

const promise = app.service('messages').get(1, {
app.service('messages').get(1, {
connection: {
signal: controller.signal
}
})

promise.abort()
controller.abort()
```

#### Superagent
Expand Down
14 changes: 9 additions & 5 deletions packages/authentication-client/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ export class AuthenticationClient {
*
* @param force force reauthentication with the server
* @param strategy The name of the strategy to use. Defaults to `options.jwtStrategy`
* @param authParams Additional authentication parameters
* @returns The reauthentication result
*/
reAuthenticate(force = false, strategy?: string): Promise<AuthenticationResult> {
reAuthenticate(force = false, strategy?: string, authParams?: Params): Promise<AuthenticationResult> {
// Either returns the authentication state or
// tries to re-authenticate with the stored JWT and strategy
let authPromise = this.app.get('authentication')
Expand All @@ -179,10 +180,13 @@ export class AuthenticationClient {
return this.handleError(new NotAuthenticated('No accessToken found in storage'), 'authenticate')
}

return this.authenticate({
strategy: strategy || this.options.jwtStrategy,
accessToken
})
return this.authenticate(
{
strategy: strategy || this.options.jwtStrategy,
accessToken
},
authParams
)
})
this.app.set('authentication', authPromise)
}
Expand Down