diff options
| author | Georgios Andreadis <G.Andreadis@student.tudelft.nl> | 2017-10-04 23:23:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-04 23:23:09 +0200 |
| commit | fcaaae65d34003874c76e0c01134dedf94248e09 (patch) | |
| tree | 2aae1422168651e832a1904623f6f5b100fc17ec /src/containers/auth | |
| parent | 0a62dfb55c5700013d42a589b930c7448e5bff71 (diff) | |
| parent | 606d1de0be09f3597165248f65d54e158a13860c (diff) | |
Merge pull request #42 from atlarge-research/auto-reformat
Standardize code format
Diffstat (limited to 'src/containers/auth')
| -rw-r--r-- | src/containers/auth/Login.js | 83 | ||||
| -rw-r--r-- | src/containers/auth/Logout.js | 15 | ||||
| -rw-r--r-- | src/containers/auth/ProfileName.js | 14 |
3 files changed, 51 insertions, 61 deletions
diff --git a/src/containers/auth/Login.js b/src/containers/auth/Login.js index 4b008da4..de12f815 100644 --- a/src/containers/auth/Login.js +++ b/src/containers/auth/Login.js @@ -1,61 +1,56 @@ 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 { 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 + }; + + 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 />; } - render() { - if (!this.props.visible) { - return <span/>; - } - - return ( - <GoogleLogin - clientId={process.env.REACT_APP_OAUTH_CLIENT_ID} - onSuccess={this.onAuthResponse.bind(this)} - onFailure={this.onAuthResponse.bind(this)} - className="login btn btn-primary" - > - <span className='fa fa-google'/> - {' '} - <span>Login with Google</span> - </GoogleLogin> - ); - } + return ( + <GoogleLogin + clientId={process.env.REACT_APP_OAUTH_CLIENT_ID} + onSuccess={this.onAuthResponse.bind(this)} + onFailure={this.onAuthResponse.bind(this)} + className="login btn btn-primary" + > + <span className="fa fa-google" /> <span>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; diff --git a/src/containers/auth/Logout.js b/src/containers/auth/Logout.js index ec2b8842..918932f6 100644 --- a/src/containers/auth/Logout.js +++ b/src/containers/auth/Logout.js @@ -1,16 +1,13 @@ -import {connect} from "react-redux"; -import {logOut} from "../../actions/auth"; +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; diff --git a/src/containers/auth/ProfileName.js b/src/containers/auth/ProfileName.js index 27df133c..21941bd2 100644 --- a/src/containers/auth/ProfileName.js +++ b/src/containers/auth/ProfileName.js @@ -1,16 +1,14 @@ import React from "react"; -import {connect} from "react-redux"; +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; |
