Copyright | (c) digitally induced GmbH 2020 |
---|---|
Safe Haskell | None |
Synopsis
- verifyPassword :: (HasField "passwordHash" entity passwordField, VerifiyPassword passwordField) => entity -> Text -> Bool
- hashPassword :: Text -> IO Text
- generateAuthenticationToken :: IO Text
- class Lockable entity where
- maxSignInAttemps :: entity -> Int
- class VerifiyPassword a where
- verifyPassword' :: a -> Text -> Bool
Documentation
verifyPassword :: (HasField "passwordHash" entity passwordField, VerifiyPassword passwordField) => entity -> Text -> Bool Source #
Returns True
when a given non-hashed password matches the hashed password of the given user.
>>>
user <- query @User |> filterWhere (#email, "hunter2@outlook.com") |> fetchOne
>>>
verifyPassword user "hunter2"
True
hashPassword :: Text -> IO Text Source #
Creates a password hash
Example:
action CreateUserAction = do newRecord @User |> fill @'["passwordHash"] |> validateField nonEmpty #passwordHash |> ifValid \case Left user -> .. Right user -> do user <- user.passwordHash |> liftIO . hashPassword user <- createRecord user
generateAuthenticationToken :: IO Text Source #
Generates a 32 character random string
>>>
token <- generateAuthenticationToken
"11D3OAbUfL0P9KNJ09VcUfCO0S9RwI"
class VerifiyPassword a where Source #
verifyPassword' :: a -> Text -> Bool Source #
Instances
VerifiyPassword Text Source # | |
Defined in IHP.AuthSupport.Authentication | |
VerifiyPassword (Maybe Text) Source # | |
Defined in IHP.AuthSupport.Authentication |