aboutsummaryrefslogtreecommitdiffstats
path: root/helpers
diff options
context:
space:
mode:
authorLibravatar MCMXC <16797721+mcmxcdev@users.noreply.github.com>2024-02-10 18:19:14 -0700
committerLibravatar Vijay A <vraravam@users.noreply.github.com>2024-02-13 06:59:44 +0530
commit7584d2d7a7110aef0331ebfa178b2295842c59fa (patch)
tree900cd71237e6231b57936fcce77ff229cd459041 /helpers
parentupgrade recipes submodule (diff)
downloadferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.gz
ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.tar.zst
ferdium-server-7584d2d7a7110aef0331ebfa178b2295842c59fa.zip
refactor: project maintenance
- work in progress
Diffstat (limited to 'helpers')
-rw-r--r--helpers/PasswordHash.ts19
1 files changed, 8 insertions, 11 deletions
diff --git a/helpers/PasswordHash.ts b/helpers/PasswordHash.ts
index be3da2c..5c73195 100644
--- a/helpers/PasswordHash.ts
+++ b/helpers/PasswordHash.ts
@@ -1,17 +1,14 @@
1import User from 'App/Models/User'; 1import User from '#app/Models/User'
2import Hash from '@ioc:Adonis/Core/Hash'; 2import hash from '@adonisjs/core/services/hash'
3 3
4export async function handleVerifyAndReHash( 4export async function handleVerifyAndReHash(user: User, passwordToTest: string): Promise<boolean> {
5 user: User,
6 passwordToTest: string,
7): Promise<boolean> {
8 // Verify password 5 // Verify password
9 const usesLegacyHasher = /^\$2[aby]/.test(user.password); 6 const usesLegacyHasher = /^\$2[aby]/.test(user.password)
10 let isMatchedPassword = false; 7 let isMatchedPassword = false
11 8
12 isMatchedPassword = await (usesLegacyHasher 9 isMatchedPassword = await (usesLegacyHasher
13 ? Hash.use('legacy').verify(user.password, passwordToTest) 10 ? hash.use('legacy').verify(user.password, passwordToTest)
14 : Hash.verify(user.password, passwordToTest)); 11 : hash.verify(user.password, passwordToTest))
15 12
16 // TODO: For some reason this is not working (user can't login after re-hashing) 13 // TODO: For some reason this is not working (user can't login after re-hashing)
17 // rehash user password 14 // rehash user password
@@ -20,5 +17,5 @@ export async function handleVerifyAndReHash(
20 // await user.save(); 17 // await user.save();
21 // } 18 // }
22 19
23 return isMatchedPassword; 20 return isMatchedPassword
24} 21}