移除可以与同一用户创建多个会话的特性

This commit is contained in:
masnn committed 2020-05-15 13:10:41 +08:00
1 parent d04628148f
commit 3c5fdb9032
16 files changed
+120 -118

No files matched your search

+5 -5
View File
@@ -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 };