Skip to content

Commit

Permalink
fix(authentication-client): Allow to abort fetch (#3310)
Browse files Browse the repository at this point in the history
  • Loading branch information
howlettt authored Nov 27, 2023
1 parent 0cbdb03 commit ff3e104
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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

0 comments on commit ff3e104

Please sign in to comment.