Skip to content

Commit fcc3f0d

Browse files
committed
refactor: update login logic with new async hashing
This adds the proper await logic for the hashing of passwords.
1 parent fd3cb6c commit fcc3f0d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/node/routes/login.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ router.post("/", async (req, res) => {
7777
? isHashLegacyMatch(req.body.password, req.args["hashed-password"])
7878
: req.args.password && safeCompare(req.body.password, req.args.password)
7979
) {
80-
const hashedPassword = req.args["hashed-password"] ? hashLegacy(req.body.password) : hash(req.body.password)
80+
// NOTE@jsjoeio:
81+
// We store the hashed password as a cookie. In order to be backwards-comptabile for the folks
82+
// using sha256 (the original hashing algorithm), we need to check the hashed-password in the req.args
83+
// TODO all of this logic should be cleaned up honestly. The current implementation only checks for a hashed-password
84+
// but doesn't check which algorithm they are using.
85+
const hashedPassword = req.args["hashed-password"] ? hashLegacy(req.body.password) : await hash(req.body.password)
8186
// The hash does not add any actual security but we do it for
8287
// obfuscation purposes (and as a side effect it handles escaping).
8388
res.cookie(Cookie.Key, hashedPassword, {

0 commit comments

Comments
 (0)