Skip to content

Instantly share code, notes, and snippets.

@charlesdarkwind
Created May 15, 2017 15:23
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 charlesdarkwind/6bf52a91ef2c0f418aa2395aaea0d383 to your computer and use it in GitHub Desktop.
Save charlesdarkwind/6bf52a91ef2c0f418aa2395aaea0d383 to your computer and use it in GitHub Desktop.
class Login extends React.Component {
componentWillMount() {
base.onAuth((user) => {
if(user) {
this.props.setUser(user.displayName, user.email, user.photoURL, user.uid);
}
});
}
authenticate(provider) {
base.authWithOAuthPopup(provider, authHandler);
}
unauth() {
base.unauth();
this.props.removeUser();
}
renderContent() {
if (this.props.user.uid) {
return (
<div>
<div className="userInfo">
<div>{this.props.user.name}</div>
<div className="photoUser"><img src={this.props.user.photoURL}/></div>
<div className="adress">
</div>
</div>
<Button bsStyle="warning" className="unauth" onClick={() => this.unauth()}>Déconnexion</Button>
</div>
)
} else {
<Button bsStyle="danger" className="google" onClick={() => this.authenticate('google')}>Connexion avec Google</Button>
}
}
render() {
return (
<div>
<div className="loginWrap">
{this.renderContent()}
</div>
</div>
)
}
}
export default Login;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment