mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: support bearer token auth
This commit is contained in:
1 parent
4782b58140
commit
4b1916d324
2 files changed
+5
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.11.1",
|
"version": "3.11.2",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -509,7 +509,10 @@ export class Handler extends HandlerCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getSession() {
|
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);
|
this.session = await token.get(sid, token.TYPE_SESSION);
|
||||||
if (!this.session) this.session = { uid: 0 };
|
if (!this.session) this.session = { uid: 0 };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user