IHP Api Reference
Copyright(c) digitally induced GmbH 2020
Safe HaskellNone

IHP.AuthSupport.Authentication

Description

 
Synopsis

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 Lockable entity where Source #

Methods

maxSignInAttemps :: entity -> Int Source #

class VerifiyPassword a where Source #

Methods

verifyPassword' :: a -> Text -> Bool Source #

Instances

Instances details
VerifiyPassword Text Source # 
Instance details

Defined in IHP.AuthSupport.Authentication

VerifiyPassword (Maybe Text) Source # 
Instance details

Defined in IHP.AuthSupport.Authentication