carpe / elm-data / ElmData.Session

Sessions exist to hold all state associated with your requests.

Right now that's just Auth data, but I think this could also be a great place for cached data to live as well.


type Session
    = Unauthenticated
    | Active SessionData

The Session


type alias SessionData =
{ authToken : String
, expiration : Basics.Int
, permissions : List String 
}

Data related to an authenticated session

checkSessionExpiration : Time.Posix -> SessionData -> Result SessionFailure SessionData

Check if session is expired

checkError : Http.Error -> Maybe SessionFailure

Check if a request failure was caused by the session


type SessionFailure
    = Failure String
    | Corrupt
    | ExpiredSession

Result of the Creation of a Session