Add hashedPassword config (#2409)

Resolve #2225.
This commit is contained in:
SPGoding
2020-12-08 14:54:17 -06:00
committed by GitHub
parent ff1da17496
commit 1dd7e4b4e1
6 changed files with 60 additions and 6 deletions

View File

@ -52,7 +52,12 @@ export const authenticated = (req: express.Request): boolean => {
return true
case AuthType.Password:
// The password is stored in the cookie after being hashed.
return req.args.password && req.cookies.key && safeCompare(req.cookies.key, hash(req.args.password))
return !!(
req.cookies.key &&
(req.args.hashedPassword
? safeCompare(req.cookies.key, req.args.hashedPassword)
: req.args.password && safeCompare(req.cookies.key, hash(req.args.password)))
)
default:
throw new Error(`Unsupported auth type ${req.args.auth}`)
}