core: support bearer token auth

pull/334/head
undefined 3 years ago
parent 4782b58140
commit 4b1916d324

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.11.1",
"version": "3.11.2",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",

@ -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 };
}

Loading…
Cancel
Save