It seems like the easiest approach at this point is a combination of binding a context type as the first argument to your update functions and sending the Navigation.newUrl command from the updateUrl function (used by Navigation).
urlUpdate : Context -> Navigation.Location -> ( Model, Cmd a ) and the rest of the update functions: update : Context -> a -> Model -> ( Model, Cmd a ) On Wednesday, July 6, 2016 at 2:05:25 PM UTC-4, Erik Lott wrote: > > *Is there an idiomatic/proven way to approach Authentication in an Elm > single page app?* Sadly, there are very few resources online that touch > on authentication, yet it's an unavoidable part of SPA development. It > would be great if this discussion could serve as the best answer to this > question. > > In our case, I am evaluating Elm for a Single Page Application. We have a > simple json api, as follows: > > The API: > > > - POST /sessions - post a username/password. If the credentials are > authentic, it returns 200 OK along with a secure http-only cookie. > - GET /me - returns 200 OK with user record or 401 Unauthorized > > > Our Elm requirements: > > - When the client app loads, it makes a request to /me to see if the > user is currently logged in. If 200 OK, store the current user in elm and > display to the Dashboard page. If not, display the login page. > - On a successful login, make a request to /me to retrieve the current > user record, store the current user in elm, and display the Dashboard > page. > - If an API response ever returns 401 Unauthorized, remove the current > user record on the elm model, and display the login page > > > I'm sure that any guidance from community would be appreciated by all! > > > -- 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.
