Add finished/
This commit is contained in:
18
finished/src/Data/Session.elm
Normal file
18
finished/src/Data/Session.elm
Normal file
@@ -0,0 +1,18 @@
|
||||
module Data.Session exposing (Session, attempt)
|
||||
|
||||
import Data.AuthToken exposing (AuthToken)
|
||||
import Data.User exposing (User)
|
||||
|
||||
|
||||
type alias Session =
|
||||
{ user : Maybe User }
|
||||
|
||||
|
||||
attempt : String -> (AuthToken -> Cmd msg) -> Session -> ( List String, Cmd msg )
|
||||
attempt attemptedAction toCmd session =
|
||||
case Maybe.map .token session.user of
|
||||
Nothing ->
|
||||
( [ "You have been signed out. Please sign back in to " ++ attemptedAction ++ "." ], Cmd.none )
|
||||
|
||||
Just token ->
|
||||
( [], toCmd token )
|
||||
Reference in New Issue
Block a user