summaryrefslogtreecommitdiff
path: root/frontend/src/containers/auth
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/containers/auth')
-rw-r--r--frontend/src/containers/auth/Login.js100
-rw-r--r--frontend/src/containers/auth/Logout.js18
-rw-r--r--frontend/src/containers/auth/ProfileName.js18
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