diff --git a/index.md b/index.md index 9e1b8fa..6a6179c 100644 --- a/index.md +++ b/index.md @@ -15,9 +15,6 @@ Passwordless ![Banner](img/banner-biometric-auth.svg) - - - --- @@ -34,8 +31,15 @@ It's really simple. Authentication can be triggered by a simple link, with no co These buttons are just links.
- Sign in - Sign out + + Sign in +
For more information on how this works, consult the [documentation](https://passwordless.id/docs/1_big_picture) or to get started quickly, take a look at the "Usage" demos. diff --git a/js/sign-in-with.js b/js/sign-in-with.js index 88e9512..8930f19 100644 --- a/js/sign-in-with.js +++ b/js/sign-in-with.js @@ -1,45 +1,15 @@ -import passwordless from 'https://unpkg.com/@passwordless-id/connect' - -// the information requested from the profile -const scope = 'openid avatar email' - -window.onClickSignIn = () => { - // performs a redirect to let the user authenticate and/or authorize this app - passwordless.auth({ scope }) -} - -window.onClickSignOut = async () => { - // performs a redirect to let the user sign out - passwordless.logout() -} +import passwordless from 'https://unpkg.com/@passwordless-id/connect@1.2.0/dist/connect.min.js' async function init() { // retrieves the user profile and `id_token` if available - const user = await passwordless.id({ scope }) + const user = await passwordless.id({ scope: 'openid avatar' }) if (user.signedIn && user.scopeGranted) { console.log(user) - showUser(user) - } - else { - showSignIn() + document.getElementById('portrait').src = user.profile.picture + document.getElementById('nickname').textContent = user.profile.nickname + document.getElementById('sign-in').hidden = true + document.getElementById('profile').hidden = false } } -init() - -function showUser(user) { - document.getElementById('picture').src = user.profile.picture - document.getElementById('nickname').textContent = user.profile.nickname - document.querySelector('#output code').textContent = JSON.stringify(user, null, ' ') - - document.getElementById('spinner').hidden = true - document.getElementById('profile').hidden = false - document.getElementById('output').hidden = false - document.getElementById('sign-out').hidden = false - -} - -function showSignIn() { - document.getElementById('spinner').hidden = true - document.getElementById('sign-in').hidden = false -} \ No newline at end of file +init() \ No newline at end of file