Skip to content

Instantly share code, notes, and snippets.

@agnelvishal
Last active October 12, 2019 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agnelvishal/9b38f4dfca025828e13e5d8afadfbf5f to your computer and use it in GitHub Desktop.
Save agnelvishal/9b38f4dfca025828e13e5d8afadfbf5f to your computer and use it in GitHub Desktop.
<script src="https://unpkg.com/blockstack@19.2.1/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