Skip to content

Instantly share code, notes, and snippets.

@MonadicT
Created July 31, 2018 19:06
Show Gist options
  • Select an option

  • Save MonadicT/8fa22ae8494292c82a67f0c523aa270b to your computer and use it in GitHub Desktop.

Select an option

Save MonadicT/8fa22ae8494292c82a67f0c523aa270b to your computer and use it in GitHub Desktop.
elm-auth-handle-auth
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