mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
migrate-hustoj: fix password check
This commit is contained in:
1 parent
11cc42b943
commit
0934f79cfc
4 files changed
+6
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.1.43",
|
||||
"version": "3.1.44",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -125,9 +125,9 @@ class UserLoginHandler extends Handler {
|
||||
this.session.uid = udoc._id;
|
||||
this.session.scope = PERM.PERM_ALL.toString();
|
||||
this.session.save = rememberme;
|
||||
this.response.redirect = redirect || (this.request.referer || '/login').endsWith('/login')
|
||||
this.response.redirect = redirect || ((this.request.referer || '/login').endsWith('/login')
|
||||
? this.url('homepage')
|
||||
: this.request.referer;
|
||||
: this.request.referer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ const RE_MD5 = /^[\da-f]{32}$/;
|
||||
function hash($password: string, $saved: string) {
|
||||
$password = md5($password);
|
||||
if (RE_MD5.test($saved)) return $password === $saved;
|
||||
const $svd = Buffer.from($saved, 'base64').toString();
|
||||
const $salt = $svd.substr(20);
|
||||
const $svd = Buffer.from($saved, 'base64').toString('hex');
|
||||
const $salt = Buffer.from($svd.substr(40), 'hex').toString();
|
||||
const $hash = Buffer.concat([
|
||||
Buffer.from(sha1($password + $salt), 'hex'),
|
||||
Buffer.from($salt),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/migrate-hustoj",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"main": "package.json",
|
||||
"repository": "git@github.com:hydro-dev/Hydro.git",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
|
||||
Reference in new issue
Block a user