Wheb-0.1.0.0: The frictionless WAI Framework

Safe HaskellNone

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 mSource

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 mSource

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 whereSource

Interface for creating Auth backends

class AuthState a whereSource

Minimal implementation for a

Methods

getAuthUser :: a -> PossibleUserSource

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

class AuthBackend c whereSource

Interface for creating Auth backends

Instances

AuthBackend UserData

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

Utils