mirror of
https://github.com/coder/code-server.git
synced 2025-08-01 19:30:05 +08:00
@ -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}`)
|
||||
}
|
||||
|
Reference in New Issue
Block a user