mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
移除可以与同一用户创建多个会话的特性
This commit is contained in:
1 parent
d04628148f
commit
3c5fdb9032
16 files changed
+120
-118
No files matched your search
@@ -151,7 +151,10 @@ class Handler {
|
||||
if (bdoc) throw new BlacklistedError(this.request.ip);
|
||||
this.user = await user.getById(this.session.uid);
|
||||
if (!this.user) throw new UserNotFoundError(this.session.uid);
|
||||
[this.csrfToken] = await token.add(token.TYPE_CSRF_TOKEN, 600, { path: this.request.path });
|
||||
[this.csrfToken] = await token.add(token.TYPE_CSRF_TOKEN, 600, {
|
||||
path: this.request.path,
|
||||
uid: this.session.uid,
|
||||
});
|
||||
this.preferJson = (this.request.headers.accept || '').includes('application/json');
|
||||
}
|
||||
|
||||
@@ -321,7 +324,6 @@ class ConnectionHandler {
|
||||
_: (str) => (str ? str.toString().translate(this.user.language) : ''),
|
||||
user: this.user,
|
||||
}));
|
||||
console.timeEnd(name);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -335,9 +337,7 @@ class ConnectionHandler {
|
||||
|
||||
async ___prepare() {
|
||||
try {
|
||||
this.session = {
|
||||
uid: await token.get(this.request.params.token, token.TYPE_CSRF_TOKEN),
|
||||
};
|
||||
this.session = await token.get(this.request.params.token, token.TYPE_CSRF_TOKEN);
|
||||
await token.delete(this.request.params.token, token.TYPE_CSRF_TOKEN);
|
||||
} catch (e) {
|
||||
this.session = { uid: 1 };
|
||||
|
||||
Reference in new issue
Block a user