[elm-discuss] Re: Checking JWT Token expiry and Time
That should read Ok result -> result I think. Haven't managed to test it properly yet. Will need to write some unit tests. -- 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 elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[elm-discuss] Re: Checking JWT Token expiry and Time
On Monday, 3 April 2017 00:21:14 UTC+12, Simon wrote: > > Sounds like you need this function > http://package.elm-lang.org/packages/simonh1000/elm-jwt/5.0.0/Jwt#isExpired > >> >> Cheers. Yep. I've got it working now I think. It wasn't as bad as I thought, was reading too much old Elm pages. :) Here's where I got to. I used a subscription to get the time updating every few seconds and and an update function to receive the time check for expiry, and then at that point calling this. tokenExpired : Model -> Bool tokenExpired model = let expiryResult = case ( model.theTime, model.authenticationModel ) of ( Just time, Auth.LoggedIn user ) -> isExpired time user.token _ -> Ok False in case expiryResult of Ok result -> False Err _ -> True -- 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 elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[elm-discuss] Re: Checking JWT Token expiry and Time
Sounds like you need this function http://package.elm-lang.org/packages/simonh1000/elm-jwt/5.0.0/Jwt#isExpired If there is something missing in elm-jwt, let me know and I'll see if it can be added (or you could send a PR) On Sunday, 2 April 2017 05:44:29 UTC+2, Richard Wood wrote: > > Hi All > > I'm working on a base application involving authentication, Auth0 and AWS > access. There's a lot of useful starter scripts and examples around - hats > off to the community - so I'm basically pulling stuff together for > server-less projects and so I can learn elm and authentication. > > I'd be keen for anyone to have a look and give me some feedback: > Elm repository https://github.com/rwoodnz/elm-base > AWS repository https://github.com/rwoodnz/aws-base > > *My question* > On entry I pop up the Auth0 lock if the user has not got an existing > token. My next stage is to add a check or checks for Token expiry. I want > to do that in the code and not make a call to Auth0 or rely on a bad > response from the API. > > I've found the very useful-looking JWT library and the Time functionality > and am trying not to despair at the amount of code it may take! > > Is there a simpler way? Should I just port out to Javascript as it would > only be a little function there? I'm really trying to avoid that in > principle and so as to force my Elm learning. > > Richard > > > -- 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 elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.