import PropTypes from 'prop-types'; import React from 'react'; import { reduxForm } from 'redux-form'; import { Link, browserHistory } from 'react-router'; import InlineSVG from 'react-inlinesvg'; import { Helmet } from 'react-helmet'; import { validateAndLoginUser } from '../actions'; import LoginForm from '../components/LoginForm'; import { validateLogin } from '../../../utils/reduxFormUtils'; import GithubButton from '../components/GithubButton'; import GoogleButton from '../components/GoogleButton'; const exitUrl = require('../../../images/exit.svg'); const logoUrl = require('../../../images/p5js-logo.svg'); class LoginView extends React.Component { constructor(props) { super(props); this.closeLoginPage = this.closeLoginPage.bind(this); this.gotoHomePage = this.gotoHomePage.bind(this); } closeLoginPage() { browserHistory.push(this.props.previousPath); } gotoHomePage() { browserHistory.push('/'); } render() { if (this.props.user.authenticated) { this.gotoHomePage(); return null; } return (
p5.js Web Editor | Login

Log In

Or

Don't have an account?  Sign Up

Forgot your password?  Reset your password

); } } function mapStateToProps(state) { return { user: state.user, previousPath: state.ide.previousPath }; } function mapDispatchToProps() { return { validateAndLoginUser }; } LoginView.propTypes = { previousPath: PropTypes.string.isRequired, user: PropTypes.shape({ authenticated: PropTypes.bool }) }; LoginView.defaultProps = { user: { authenticated: false } }; export default reduxForm({ form: 'login', fields: ['email', 'password'], validate: validateLogin }, mapStateToProps, mapDispatchToProps)(LoginView);