diff options
Diffstat (limited to 'opendc-web/opendc-web-ui/src/containers/auth/Login.js')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/containers/auth/Login.js | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/opendc-web/opendc-web-ui/src/containers/auth/Login.js b/opendc-web/opendc-web-ui/src/containers/auth/Login.js index b0da0d0e..8459ef5f 100644 --- a/opendc-web/opendc-web-ui/src/containers/auth/Login.js +++ b/opendc-web/opendc-web-ui/src/containers/auth/Login.js @@ -1,43 +1,18 @@ import React from 'react' -import GoogleLogin from 'react-google-login' -import { useDispatch } from 'react-redux' -import { logIn } from '../../redux/actions/auth' import { Button } from 'reactstrap' +import { useAuth } from '../../auth' function Login({ visible, className }) { - const dispatch = useDispatch() - - const onLogin = (payload) => dispatch(logIn(payload)) - const onAuthResponse = (response) => { - onLogin({ - email: response.getBasicProfile().getEmail(), - givenName: response.getBasicProfile().getGivenName(), - familyName: response.getBasicProfile().getFamilyName(), - googleId: response.googleId, - authToken: response.getAuthResponse().id_token, - expiresAt: response.getAuthResponse().expires_at, - }) - } - const onAuthFailure = (error) => { - // TODO Show error alert - console.error(error) - } + const { loginWithRedirect } = useAuth() if (!visible) { return <span /> } return ( - <GoogleLogin - clientId={process.env.NEXT_PUBLIC_OAUTH_CLIENT_ID} - onSuccess={onAuthResponse} - onFailure={onAuthFailure} - render={(renderProps) => ( - <Button color="primary" onClick={renderProps.onClick} className={className}> - <span aria-hidden className="fa fa-google" /> Login with Google - </Button> - )} - /> + <Button color="primary" onClick={() => loginWithRedirect()} className={className}> + <span aria-hidden className="fa fa-sign-in" /> Sign In + </Button> ) } |
