From 5900e6290431597d4c0c48857b70e19d8858ab29 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Thu, 19 Sep 2019 13:38:27 -0400 Subject: [PATCH] unify navigation for authentication pages, add authorization to front end, fixes #650 --- client/components/Nav.jsx | 18 ++-- client/modules/User/components/APIKeyForm.jsx | 3 +- client/modules/User/pages/AccountView.jsx | 52 ++++++------ .../User/pages/EmailVerificationView.jsx | 35 ++------ client/modules/User/pages/LoginView.jsx | 16 +--- client/modules/User/pages/NewPasswordView.jsx | 73 +++++----------- .../modules/User/pages/ResetPasswordView.jsx | 85 +++++++------------ client/modules/User/pages/SignupView.jsx | 35 ++------ client/routes.jsx | 12 +-- client/styles/base/_base.scss | 4 + client/styles/components/_account.scss | 14 +++ client/styles/components/_api-key.scss | 5 ++ client/styles/layout/_user.scss | 12 +++ client/utils/auth.js | 29 +++++++ package-lock.json | 37 ++++++++ package.json | 1 + server/controllers/user.controller.js | 7 +- 17 files changed, 220 insertions(+), 218 deletions(-) create mode 100644 client/utils/auth.js diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx index ab06441a..9a7fa1d4 100644 --- a/client/components/Nav.jsx +++ b/client/components/Nav.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { connect } from 'react-redux'; import { withRouter } from 'react-router'; -import { Link } from 'react-router'; +import { Link, browserHistory } from 'react-router'; import InlineSVG from 'react-inlinesvg'; import classNames from 'classnames'; import * as IDEActions from '../modules/IDE/actions/ide'; @@ -93,11 +93,12 @@ class Nav extends React.PureComponent { } handleNew() { - if (!this.props.unsavedChanges) { + const { unsavedChanges, warnIfUnsavedChanges } = this.props; + if (!unsavedChanges) { this.props.showToast(1500); this.props.setToastText('Opened new sketch.'); this.props.newProject(); - } else if (this.props.warnIfUnsavedChanges()) { + } else if (warnIfUnsavedChanges && warnIfUnsavedChanges()) { this.props.showToast(1500); this.props.setToastText('Opened new sketch.'); this.props.newProject(); @@ -166,6 +167,8 @@ class Nav extends React.PureComponent { handleLogout() { this.props.logoutUser(); + // if you're on the settings page, probably. + browserHistory.push('/'); this.setDropdown('none'); } @@ -535,13 +538,13 @@ class Nav extends React.PureComponent { renderUnauthenticatedUserMenu(navDropdownState) { return (