@@ -5,7 +5,7 @@ import * as path from "path"
5
5
import safeCompare from "safe-compare"
6
6
import { rootPath } from "../constants"
7
7
import { authenticated , getCookieDomain , redirect , replaceTemplates } from "../http"
8
- import { hash , hashLegacy , humanPath , isHashLegacyMatch } from "../util"
8
+ import { hash , hashLegacy , humanPath , isHashLegacyMatch , isHashMatch } from "../util"
9
9
10
10
export enum Cookie {
11
11
Key = "key" ,
@@ -72,6 +72,14 @@ router.post("/", async (req, res) => {
72
72
throw new Error ( "Missing password" )
73
73
}
74
74
75
+ // this logic below is flawed
76
+ const theHash = await hash ( req . body . password )
77
+ const hashedPassword = req . args [ "hashed-password" ] || ""
78
+ const match = await isHashMatch ( req . body . password , hashedPassword )
79
+ // console.log(`The actual hash: ${theHash}`)
80
+ // console.log(`hashed-password from config: ${hashedPassword}`)
81
+ // console.log(theHash, hashedPassword)
82
+ console . log ( `is it a match??? ${ match } ` )
75
83
if (
76
84
req . args [ "hashed-password" ]
77
85
? isHashLegacyMatch ( req . body . password , req . args [ "hashed-password" ] )
@@ -82,6 +90,7 @@ router.post("/", async (req, res) => {
82
90
// using sha256 (the original hashing algorithm), we need to check the hashed-password in the req.args
83
91
// TODO all of this logic should be cleaned up honestly. The current implementation only checks for a hashed-password
84
92
// but doesn't check which algorithm they are using.
93
+ console . log ( `What is this? ${ req . args [ "hashed-password" ] } ` , Boolean ( req . args [ "hashed-password" ] ) )
85
94
const hashedPassword = req . args [ "hashed-password" ] ? hashLegacy ( req . body . password ) : await hash ( req . body . password )
86
95
// The hash does not add any actual security but we do it for
87
96
// obfuscation purposes (and as a side effect it handles escaping).
0 commit comments