Skip to content

Commit 54b5656

Browse files
committed
Promote removeTokenOnError to auth options
1 parent fd4719b commit 54b5656

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

packages/authentication-client/src/core.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface AuthenticationClientOptions {
2929
jwtStrategy: string;
3030
path: string;
3131
Authentication: ClientConstructor;
32+
removeTokenOnError (error?: Error): boolean;
3233
}
3334

3435
export class AuthenticationClient {
@@ -107,15 +108,11 @@ export class AuthenticationClient {
107108
});
108109
}
109110

110-
removeTokenOnError () {
111-
return true
112-
}
113-
114111
removeAccessToken (error?: Error) {
115-
if (this.removeTokenOnError(error)) {
112+
if (this.options.removeTokenOnError(error)) {
116113
return this.storage.removeItem(this.options.storageKey);
117114
} else {
118-
return Promise.resolve()
115+
return Promise.resolve();
119116
}
120117
}
121118

packages/authentication-client/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export const defaults: AuthenticationClientOptions = {
3232
jwtStrategy: 'jwt',
3333
path: '/authentication',
3434
Authentication: AuthenticationClient,
35-
storage: defaultStorage
35+
storage: defaultStorage,
36+
removeTokenOnError: () => true
3637
};
3738

3839
const init = (_options: Partial<AuthenticationClientOptions> = {}) => {

0 commit comments

Comments
 (0)