On Friday, September 16, 2016 at 2:49:25 PM UTC+1, Rupert Smith wrote:
>
> I think I am going to try the solution from the "Inter-Component
> Communication in 0.17" thread. Which is to create pairs of messaging ports.
>
The module I came with is below. I can import it anywhere and make use of
these auth functions - this will come in handy for setting the not authed
state on any http request that fails with a 401.
I just need to think about how to add functions to query the auth state on
this module too, as it would also be nice to be able to query that all over
the place too. Something like
isLoggedIn : Bool
hasPermission : String -> Bool
would cover my needs. Anyway, here is the Auth module:
port module Auth exposing (..)
type alias Credentials =
{ username : String
, password : String
}
login : Credentials -> Cmd msg
login authRequest =
sendLogin authRequest
logout : Cmd msg
logout =
sendLogout ()
unauthed : Cmd msg
unauthed =
sendUnauthed ()
port sendLogin : Credentials -> Cmd msg
port sendLogout : () -> Cmd msg
port sendUnauthed : () -> Cmd msg
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.