diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-01 13:33:31 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:47:17 +0200 |
| commit | de8f12d74faef5fa3f9e38d1340948cab2d06ea3 (patch) | |
| tree | 678bf1af3e5fa2334f0df43388d45294785bbf1e /frontend/src/containers/auth | |
| parent | 44236756c4cf689806dc17c6950a2cff3e9227bf (diff) | |
Manually generate IDs
Diffstat (limited to 'frontend/src/containers/auth')
| -rw-r--r-- | frontend/src/containers/auth/Login.js | 100 | ||||
| -rw-r--r-- | frontend/src/containers/auth/Logout.js | 18 | ||||
| -rw-r--r-- | frontend/src/containers/auth/ProfileName.js | 18 |
3 files changed, 67 insertions, 69 deletions
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 <span />; + onAuthFailure(error) { + console.error(error) } - return ( - <GoogleLogin - clientId={process.env.REACT_APP_OAUTH_CLIENT_ID} - onSuccess={this.onAuthResponse.bind(this)} - onFailure={this.onAuthFailure.bind(this)} - render={renderProps => ( - <span onClick={renderProps.onClick} className="login btn btn-primary"> - <span className="fa fa-google" /> Login with Google + render() { + if (!this.props.visible) { + return <span/> + } + + return ( + <GoogleLogin + clientId={process.env.REACT_APP_OAUTH_CLIENT_ID} + onSuccess={this.onAuthResponse.bind(this)} + onFailure={this.onAuthFailure.bind(this)} + render={renderProps => ( + <span onClick={renderProps.onClick} className="login btn btn-primary"> + <span className="fa fa-google"/> Login with Google </span> - )} - /> - ); - } + )} + > + </GoogleLogin> + ) + } } 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 }) => <span>{text}</span>; +const SpanElement = ({ text }) => <span>{text}</span> -const ProfileName = connect(mapStateToProps)(SpanElement); +const ProfileName = connect(mapStateToProps)(SpanElement) -export default ProfileName; +export default ProfileName |
