Last active
October 12, 2019 10:20
-
-
Save agnelvishal/9b38f4dfca025828e13e5d8afadfbf5f to your computer and use it in GitHub Desktop.
This file contains 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
<script src="https://unpkg.com/[email protected]/dist/blockstack.js" integrity="sha384-+qYCYoUGzsMLAzHm80c4DyhbWgHBBb2N0RFqsg7Lws5ljtBtj/IwpgxZkiR7j7lp" crossorigin="anonymous"></script> | |
<button id="signin-button">Sign in with Blockstack </button> | |
<script> | |
const appConfig = new blockstack.AppConfig(); | |
const userSession = new blockstack.UserSession({ appConfig: appConfig }); | |
document.getElementById('signin-button').addEventListener('click', function() { | |
userSession.redirectToSignIn(); | |
}); | |
if (userSession.isUserSignedIn()) { | |
document.getElementById('signin-button').remove(); | |
storePref(); | |
} else if (userSession.isSignInPending()) { | |
userSession.handlePendingSignIn() | |
.then(() => { | |
console.log("Signed in by pending"); | |
document.getElementById('signin-button').remove(); | |
storePref(); | |
}) | |
} | |
function storePref() | |
{ | |
console.log("Logged in") | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment