Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
hello-hub
document.addEventListener("DOMContentLoaded", function(event) {
const authRequest = blockstack.makeAuthRequest(
blockstack.generateAndStoreTransitKey(),
'http://localhost:5000/',
'http://localhost:5000/manifest.json',
['store_write', 'publish_data'],
'http://localhost:5000/',
blockstack.nextHour().getTime(), {
solicitGaiaHubUrl: true
} // new options param
);
document.getElementById('signin-button').addEventListener('click', function(event) {
event.preventDefault()
blockstack.redirectToSignInWithAuthRequest(authRequest)
})
document.getElementById('signout-button').addEventListener('click', function(event) {
event.preventDefault()
blockstack.signUserOut(window.location.href)
})
function showProfile(profile) {
var person = new blockstack.Person(profile)
document.getElementById('heading-name').innerHTML = person.name() ? person.name() : "Nameless Person"
if(person.avatarUrl()) {
document.getElementById('avatar-image').setAttribute('src', person.avatarUrl())
}
document.getElementById('section-1').style.display = 'none'
document.getElementById('section-2').style.display = 'block'
}
if (blockstack.isUserSignedIn()) {
var profile = blockstack.loadUserData().profile
showProfile(profile)
} else if (blockstack.isSignInPending()) {
blockstack.handlePendingSignIn().then(function(userData) {
window.location = window.location.origin
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.