在session无效时切换至guest

This commit is contained in:
undefined committed 2020-07-30 13:16:10 +08:00
1 parent 2bf6adbaa0
commit 875bf696e2
4 files changed
+45 -34

No files matched your search

+9
View File
@@ -380,6 +380,15 @@ export class Handler {
token.TYPE_TOKEN, 600, { uid: this.session.uid, domainId },
),
]);
if (!this.user) {
this.session.uid = 0;
[this.user, this.UIContext.token] = await Promise.all([
user.getById(domainId, this.session.uid),
token.createOrUpdate(
token.TYPE_TOKEN, 600, { uid: this.session.uid, domainId },
),
]);
}
this.csrfToken = this.getCsrfToken(this.session._id || String.random(32));
this.UIContext.csrfToken = this.csrfToken;
}