From 7584d2d7a7110aef0331ebfa178b2295842c59fa Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:19:14 -0700 Subject: refactor: project maintenance - work in progress --- helpers/PasswordHash.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'helpers') 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 @@ -import User from 'App/Models/User'; -import Hash from '@ioc:Adonis/Core/Hash'; +import User from '#app/Models/User' +import hash from '@adonisjs/core/services/hash' -export async function handleVerifyAndReHash( - user: User, - passwordToTest: string, -): Promise { +export async function handleVerifyAndReHash(user: User, passwordToTest: string): Promise { // Verify password - const usesLegacyHasher = /^\$2[aby]/.test(user.password); - let isMatchedPassword = false; + const usesLegacyHasher = /^\$2[aby]/.test(user.password) + let isMatchedPassword = false isMatchedPassword = await (usesLegacyHasher - ? Hash.use('legacy').verify(user.password, passwordToTest) - : Hash.verify(user.password, passwordToTest)); + ? hash.use('legacy').verify(user.password, passwordToTest) + : hash.verify(user.password, passwordToTest)) // TODO: For some reason this is not working (user can't login after re-hashing) // rehash user password @@ -20,5 +17,5 @@ export async function handleVerifyAndReHash( // await user.save(); // } - return isMatchedPassword; + return isMatchedPassword } -- cgit v1.2.3-70-g09d2