migrate-hustoj: fix password check

This commit is contained in:
undefined committed 2021-11-30 23:10:15 +08:00
1 parent 11cc42b943
commit 0934f79cfc
4 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "3.1.43", "version": "3.1.44",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+2 -2
View File
@@ -125,9 +125,9 @@ class UserLoginHandler extends Handler {
this.session.uid = udoc._id; this.session.uid = udoc._id;
this.session.scope = PERM.PERM_ALL.toString(); this.session.scope = PERM.PERM_ALL.toString();
this.session.save = rememberme; 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.url('homepage')
: this.request.referer; : this.request.referer);
} }
} }
+2 -2
View File
@@ -5,8 +5,8 @@ const RE_MD5 = /^[\da-f]{32}$/;
function hash($password: string, $saved: string) { function hash($password: string, $saved: string) {
$password = md5($password); $password = md5($password);
if (RE_MD5.test($saved)) return $password === $saved; if (RE_MD5.test($saved)) return $password === $saved;
const $svd = Buffer.from($saved, 'base64').toString(); const $svd = Buffer.from($saved, 'base64').toString('hex');
const $salt = $svd.substr(20); const $salt = Buffer.from($svd.substr(40), 'hex').toString();
const $hash = Buffer.concat([ const $hash = Buffer.concat([
Buffer.from(sha1($password + $salt), 'hex'), Buffer.from(sha1($password + $salt), 'hex'),
Buffer.from($salt), Buffer.from($salt),
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/migrate-hustoj", "name": "@hydrooj/migrate-hustoj",
"version": "0.1.2", "version": "0.1.3",
"main": "package.json", "main": "package.json",
"repository": "git@github.com:hydro-dev/Hydro.git", "repository": "git@github.com:hydro-dev/Hydro.git",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",