Closed ruile closed 6 months ago
The PasswordHash
data constructor is free to use, so you can construct your own PasswordHash
from any Text
hashFromDB :: PasswordHash Bcrypt
hashFromDB = PasswordHash textYouGotFromDB
Or am I not understanding your issue?
Hi Vlix, thank you for helping a Haskell newbie like me! I embarrassingly mixed up PasswordHash
constructor with the PasswordHash a
newtype. Now I get it 😄
No worries :) Good luck on your Haskell journey!
Context Hash a password, and store it in a Postgres database using
postgresql-simple
libraryIntent To retrieve the hashed password from the database, and compare it with a user submitted password using the
checkPassword
function.Issue Database only accepts
::Text
. Hence initial password must be converted from::PasswordHash Bcrypt
to::Text
usingunPasswordHash
.However, there is no way in the library to convert the hashed password from the database back to type
::PasswordHash Bcrypt
for usage with thecheckPassword
function, which has type signature:: Password -> PasswordHash Bcrypt -> PasswordCheck
.How can I achieve my intent? Or am I missing something here.
Thank you :)