mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: fix logout all sessions behavior (#1178)
This commit is contained in:
1 parent
809d1ac6ad
commit
dc5bcff952
2 files changed
+5
-3
No files matched your search
@@ -281,7 +281,7 @@ class HomeSecurityHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async postDeleteAllTokens() {
|
async postDeleteAllTokens() {
|
||||||
await token.delByUid(this.user._id);
|
await token.delByUid(this.user._id, token.TYPE_SESSION);
|
||||||
this.response.redirect = this.url('user_login');
|
this.response.redirect = this.url('user_login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,8 +102,10 @@ class TokenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ArgMethod
|
@ArgMethod
|
||||||
static delByUid(uid: number) {
|
static delByUid(uid: number, tokenType?: number) {
|
||||||
return TokenModel.coll.deleteMany({ uid });
|
const filter: Filter<TokenDoc> = { uid };
|
||||||
|
if (tokenType !== undefined) filter.tokenType = tokenType;
|
||||||
|
return TokenModel.coll.deleteMany(filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user