Wheb-0.2.0.0: The frictionless WAI Framework

Safe HaskellNone
LanguageHaskell2010

Web.Wheb.Plugins.Auth

Contents

Synopsis

Main functions

login :: (AuthApp a, AuthState b, MonadIO m) => UserKey -> Password -> WhebT a b m (Either AuthError AuthUser) Source

Log a user in

logout :: (AuthApp a, AuthState b, MonadIO m) => WhebT a b m () Source

Log a user out

register :: (AuthApp a, MonadIO m) => AuthUser -> Password -> WhebT a b m (Either AuthError AuthUser) Source

Register a user

getCurrentUser :: (AuthState b, MonadIO m) => WhebT a b m (Maybe AuthUser) Source

Get the current user from the handler state (Needs to be populated first with authMiddleware)

queryCurrentUser :: (AuthApp a, MonadIO m) => WhebT a b m (Maybe AuthUser) Source

Explicitly query a user with the backend. Since this is an IO hit, it is better to use the middleware and getCurrentUser

loginRequired :: (AuthState b, MonadIO m) => WhebHandlerT a b m -> WhebHandlerT a b m Source

Checks if a user is logged in with getCurrentUser and throws a 500 if they aren't.

Middleware

authMiddleware :: (AuthApp a, AuthState b, MonadIO m) => WhebMiddleware a b m Source

Auto-populates the handler state with the current user.

Types

data AuthUser Source

Constructors

AuthUser 

Instances

data AuthContainer Source

Constructors

forall r . AuthBackend r => AuthContainer r 

class SessionApp a => AuthApp a where Source

Interface for creating Auth backends

class AuthState a where Source

Minimal implementation for a

Methods

getAuthUser :: a -> PossibleUser Source

modifyAuthUser :: (PossibleUser -> PossibleUser) -> a -> a Source

class AuthBackend c where Source

Interface for creating Auth backends

Minimal complete definition

backendLogin, backendRegister, backendGetUser

Instances

AuthBackend UserData

In memory auth backend. User values will not persist after server restart.

Utils