Created
July 31, 2018 19:06
-
-
Save MonadicT/8fa22ae8494292c82a67f0c523aa270b to your computer and use it in GitHub Desktop.
elm-auth-handle-auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function handleAuthentication() { | |
| webAuth.parseHash(function(err, authResult) { | |
| if (authResult && authResult.accessToken && authResult.idToken) { | |
| window.location.hash = ''; | |
| let decodedId = jwtDecode(authResult.idToken); | |
| let profile = { accessToken: authResult.accessToken, | |
| email: decodedId.email, | |
| emailVerified: decodedId.email_verified, | |
| exp: decodedId.exp, | |
| name: decodedId.name, | |
| nickname: decodedId.nickname, | |
| picture: decodedId.picture, | |
| sub: decodedId.sub | |
| }; | |
| localStorage.setItem('profile', JSON.stringify(profile)); | |
| app.ports.authResponse.send({ | |
| err: null, | |
| ok: profile, | |
| stale: false}); | |
| } else if (err) { | |
| app.ports.authResponse.send({err: err.error, ok: null, stale: false}) | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment