Last active
December 3, 2019 17:26
-
-
Save alant/61f7ca139656faa95ca8c3427b6a2cfe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function Login(props) { | |
| const { state, dispatch } = React.useContext(AuthContext); | |
| const GITHUB_CLIENT_ID = "6e0b5f325ac2e324312c"; | |
| const GITHUB_REDIRECT_URI = process.env.REACT_APP_FRONTEND_URL + "/callback"; | |
| const handleGithubLogin = event => { | |
| event.preventDefault(); | |
| window.open(`https://github.com/login/oauth/authorize?client_id=${GITHUB_CLIENT_ID}&scope=user&redirect_uri=${GITHUB_REDIRECT_URI}`, "_self"); | |
| } | |
| return ( | |
| <div className="login-container"> | |
| {!state.isAuthenticated ? | |
| <div className="card"> | |
| <div className="container"> | |
| <h1>Login</h1> | |
| <Grid> | |
| <Grid.Row> | |
| <Grid.Column> | |
| <button onClick={handleGithubLogin}> | |
| Login with Github | |
| </button> | |
| </Grid.Column> | |
| </Grid.Row> | |
| </Grid> | |
| </div> | |
| </div> | |
| : | |
| <Redirect to="/" /> | |
| } | |
| </div> | |
| ); | |
| } | |
| export default Login; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment