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 ++++++++++++++-------------- frontend/src/containers/auth/Logout.js | 18 ++--- frontend/src/containers/auth/ProfileName.js | 18 ++--- 3 files changed, 67 insertions(+), 69 deletions(-) (limited to 'frontend/src/containers/auth') 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 diff --git a/frontend/src/containers/auth/Logout.js b/frontend/src/containers/auth/Logout.js index 918932f6..6e885fb1 100644 --- a/frontend/src/containers/auth/Logout.js +++ b/frontend/src/containers/auth/Logout.js @@ -1,13 +1,13 @@ -import { connect } from "react-redux"; -import { logOut } from "../../actions/auth"; -import LogoutButton from "../../components/navigation/LogoutButton"; +import { connect } from 'react-redux' +import { logOut } from '../../actions/auth' +import LogoutButton from '../../components/navigation/LogoutButton' const mapDispatchToProps = dispatch => { - return { - onLogout: () => dispatch(logOut()) - }; -}; + return { + onLogout: () => dispatch(logOut()), + } +} -const Logout = connect(undefined, mapDispatchToProps)(LogoutButton); +const Logout = connect(undefined, mapDispatchToProps)(LogoutButton) -export default Logout; +export default Logout diff --git a/frontend/src/containers/auth/ProfileName.js b/frontend/src/containers/auth/ProfileName.js index 21941bd2..8511a9b1 100644 --- a/frontend/src/containers/auth/ProfileName.js +++ b/frontend/src/containers/auth/ProfileName.js @@ -1,14 +1,14 @@ -import React from "react"; -import { connect } from "react-redux"; +import React from 'react' +import { connect } from 'react-redux' const mapStateToProps = state => { - return { - text: state.auth.givenName + " " + state.auth.familyName - }; -}; + return { + text: state.auth.givenName + ' ' + state.auth.familyName, + } +} -const SpanElement = ({ text }) => {text}; +const SpanElement = ({ text }) => {text} -const ProfileName = connect(mapStateToProps)(SpanElement); +const ProfileName = connect(mapStateToProps)(SpanElement) -export default ProfileName; +export default ProfileName -- cgit v1.2.3