core: support bearer token auth

This commit is contained in:
undefined committed 2022-03-29 22:45:40 +08:00
1 parent 4782b58140
commit 4b1916d324
2 files changed
+5 -2

No files matched your search

+4 -1
View File
@@ -509,7 +509,10 @@ export class Handler extends HandlerCommon {
}
async getSession() {
const sid = this.request.cookies.get('sid');
const header = this.request.headers['authorization'];
const sid = header
? header.split(' ')[1] // Just accept bearer token
: this.request.cookies.get('sid');
this.session = await token.get(sid, token.TYPE_SESSION);
if (!this.session) this.session = { uid: 0 };
}