mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 11:06:25 +08:00
feat: add logout
This commit is contained in:
@@ -16,7 +16,7 @@ import { getApis } from './apis/index.js';
|
||||
import type { Apis, WorkspaceDetail, Callback } from './apis';
|
||||
import { setDefaultAvatar } from '../utils.js';
|
||||
import { MessageCode } from '../../message';
|
||||
import { blob } from 'stream/consumers';
|
||||
import { token } from './apis/token.js';
|
||||
|
||||
export interface AffineProviderConstructorParams
|
||||
extends ProviderConstructorParams {
|
||||
@@ -213,6 +213,7 @@ export class AffineProvider extends BaseProvider {
|
||||
|
||||
public override async getUserInfo(): Promise<User | undefined> {
|
||||
const user = this._apis.token.user;
|
||||
await this.init;
|
||||
return user
|
||||
? {
|
||||
id: user.id,
|
||||
@@ -359,4 +360,9 @@ export class AffineProvider extends BaseProvider {
|
||||
});
|
||||
return to;
|
||||
}
|
||||
|
||||
public override async logout(): Promise<void> {
|
||||
token.clear();
|
||||
storage.removeItem('token');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,10 @@ class Token {
|
||||
this.callbacks.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
clear() {
|
||||
this._setToken();
|
||||
}
|
||||
}
|
||||
|
||||
export const token = new Token();
|
||||
|
||||
Reference in New Issue
Block a user