Skip to content

Instantly share code, notes, and snippets.

@elmariachi111
Created March 5, 2018 17:45
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 elmariachi111/f585fcd139275470a2b82e7a97aa1131 to your computer and use it in GitHub Desktop.
Save elmariachi111/f585fcd139275470a2b82e7a97aa1131 to your computer and use it in GitHub Desktop.
blockstagram / SigninButton.jsx
import React from 'react';
import * as blockstack from 'blockstack'
export default class SigninButton extends React.Component {
onClick (evt) {
evt.preventDefault();
if (this.props.userData) {
blockstack.signUserOut('/');
} else {
const origin = window.location.origin
blockstack.redirectToSignIn(origin, origin + '/manifest.json', ['store_write', 'publish_data']);
}
}
render() {
let btnText = this.props.userData ? `Sign out ${this.props.userData.username}` : 'Sign in'
return (
<a onClick={this.onClick.bind(this)} className="button is-primary">{btnText}</a>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment