Created
May 15, 2017 15:23
-
-
Save charlesdarkwind/6bf52a91ef2c0f418aa2395aaea0d383 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
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