From de8f12d74faef5fa3f9e38d1340948cab2d06ea3 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 1 Jul 2020 13:33:31 +0200 Subject: Manually generate IDs --- frontend/src/containers/auth/Login.js | 100 +++++++++++++++++----------------- 1 file changed, 49 insertions(+), 51 deletions(-) (limited to 'frontend/src/containers/auth/Login.js') diff --git a/frontend/src/containers/auth/Login.js b/frontend/src/containers/auth/Login.js index 15af8e62..951f6b10 100644 --- a/frontend/src/containers/auth/Login.js +++ b/frontend/src/containers/auth/Login.js @@ -1,65 +1,63 @@ -import PropTypes from "prop-types"; -import React from "react"; -import GoogleLogin from "react-google-login"; -import { connect } from "react-redux"; -import { logIn } from "../../actions/auth"; +import PropTypes from 'prop-types' +import React from 'react' +import GoogleLogin from 'react-google-login' +import { connect } from 'react-redux' +import { logIn } from '../../actions/auth' class LoginContainer extends React.Component { - static propTypes = { - visible: PropTypes.bool.isRequired, - onLogin: PropTypes.func.isRequired - }; - - onAuthResponse(response) { - this.props.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 - }); - } + static propTypes = { + visible: PropTypes.bool.isRequired, + onLogin: PropTypes.func.isRequired, + } - onAuthFailure(error) { - console.error(error); - } + onAuthResponse(response) { + this.props.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, + }) + } - render() { - if (!this.props.visible) { - return ; + onAuthFailure(error) { + console.error(error) } - return ( - ( - - Login with Google + render() { + if (!this.props.visible) { + return + } + + return ( + ( + + Login with Google - )} - /> - ); - } + )} + > + + ) + } } const mapStateToProps = (state, ownProps) => { - return { - visible: ownProps.visible - }; -}; + return { + visible: ownProps.visible, + } +} const mapDispatchToProps = dispatch => { - return { - onLogin: payload => dispatch(logIn(payload)) - }; -}; + return { + onLogin: payload => dispatch(logIn(payload)), + } +} -const Login = connect( - mapStateToProps, - mapDispatchToProps -)(LoginContainer); +const Login = connect(mapStateToProps, mapDispatchToProps)(LoginContainer) -export default Login; +export default Login -- cgit v1.2.3