增加 removeToken清除本地token

This commit is contained in:
Wang Kejun 2023-04-28 11:15:30 +08:00
parent caa92e8106
commit be6a5d702d
4 changed files with 19 additions and 9 deletions

View File

@ -17,6 +17,7 @@ export declare class Token<ED extends EntityDict, Cxt extends BackendRuntimeCont
loginWechatMp(): Promise<void>;
syncUserInfoWechatMp(): Promise<void>;
logout(): Promise<void>;
removeToken(): void;
getTokenValue(): string | undefined;
getToken(allowUnloggedIn?: boolean, context?: FrontCxt): Partial<ED["token"]["Schema"]> | undefined;
getUserId(allowUnloggedIn?: boolean, context?: FrontCxt): NonNullable<ED["token"]["Schema"]["userId"]> | undefined;

View File

@ -138,14 +138,21 @@ var Token = /** @class */ (function (_super) {
Token.prototype.logout = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
// await this.cache.exec('logout', {});
this.tokenValue = undefined;
this.storage.remove('token:token');
this.publish();
return [2 /*return*/];
switch (_a.label) {
case 0: return [4 /*yield*/, this.cache.exec('logout', {})];
case 1:
_a.sent();
this.removeToken();
return [2 /*return*/];
}
});
});
};
Token.prototype.removeToken = function () {
this.tokenValue = undefined;
this.storage.remove('token:token');
this.publish();
};
Token.prototype.getTokenValue = function () {
return this.tokenValue;
};

View File

@ -103,7 +103,11 @@ export class Token<
}
async logout() {
// await this.cache.exec('logout', {});
await this.cache.exec('logout', {});
this.removeToken();
}
removeToken() {
this.tokenValue = undefined;
this.storage.remove('token:token');
this.publish();

View File

@ -8,14 +8,12 @@ import { isWeiXin } from 'oak-frontend-base/lib/utils/utils';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(
export default function Render(
props: WebComponentProps<
EntityDict,
'userEntityGrant',
true,
{
oakLoading: boolean;
oakExecuting: boolean;
type: 'grant';
expired: boolean;
relation: boolean;