From 64c10cd1722d1b255c249ed8cc0d922d92861719 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Thu, 24 Oct 2019 19:30:21 -0400 Subject: [PATCH 1/2] Rename variable to make code more concise --- functions/handlers/users.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/handlers/users.js b/functions/handlers/users.js index a7687a9..09e96c1 100644 --- a/functions/handlers/users.js +++ b/functions/handlers/users.js @@ -245,13 +245,13 @@ exports.getUserDetails = (req, res) => { }; exports.getAuthenticatedUser = (req, res) => { - let userData = {}; + let credentials = {}; db.doc(`/users/${req.user.handle}`) .get() .then((doc) => { if (doc.exists) { - userData.credentials = doc.data(); - return res.status(200).json({userData}); + credentials = doc.data(); + return res.status(200).json({credentials}); } else { return res.status(400).json({error: "User not found."}) }}) From 021e25de8682fef8b2e7d8a8b4bb4563b629b5e6 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Thu, 24 Oct 2019 22:38:42 -0400 Subject: [PATCH 2/2] Make NavBar display login/signup/logout correctly --- .../src/components/layout/NavBar.js | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/twistter-frontend/src/components/layout/NavBar.js b/twistter-frontend/src/components/layout/NavBar.js index 5f8d28d..ceab08f 100644 --- a/twistter-frontend/src/components/layout/NavBar.js +++ b/twistter-frontend/src/components/layout/NavBar.js @@ -1,7 +1,7 @@ /* eslint-disable */ import React, { Component } from 'react'; import { Link } from 'react-router-dom'; -// import PropTypes from 'prop-types'; +import PropTypes from 'prop-types'; // Material UI stuff import AppBar from '@material-ui/core/AppBar'; @@ -11,26 +11,26 @@ import withStyles from "@material-ui/core/styles/withStyles"; // Redux stuff // import { logoutUser } from '../../redux/actions/userActions'; -// import { connect } from 'react-redux'; +import { connect } from 'react-redux'; -// const styles = { -// form: { -// textAlign: "center" -// }, -// textField: { -// marginBottom: 30 -// }, -// pageTitle: { -// marginBottom: 40 -// }, -// button: { -// positon: "relative", -// marginBottom: 30 -// }, -// progress: { -// position: "absolute" -// } -// }; +const styles = { + form: { + textAlign: "center" + }, + textField: { + marginBottom: 30 + }, + pageTitle: { + marginBottom: 40 + }, + button: { + positon: "relative", + marginBottom: 30 + }, + progress: { + position: "absolute" + } + }; @@ -38,42 +38,44 @@ import withStyles from "@material-ui/core/styles/withStyles"; export class Navbar extends Component { render() { + const authenticated = this.props.user.authenticated; return ( - - } + {!authenticated && - } + {authenticated && - } + {/* Commented out the delete button, because it should probably go on + the profile or editProfile page instead of the NavBar */} + {/* + */} ) } } -// const mapStateToProps = (state) => ({ -// user: state.user -// }) +const mapStateToProps = (state) => ({ + user: state.user +}) // const mapActionsToProps = { logoutUser }; -// Navbar.propTypes = { -// logoutUser: PropTypes.func.isRequired, -// user: PropTypes.object.isRequired, -// classes: PropTypes.object.isRequired -// } +Navbar.propTypes = { + user: PropTypes.object.isRequired, + classes: PropTypes.object.isRequired +} -// export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Navbar)); +export default connect(mapStateToProps)(withStyles(styles)(Navbar)); -export default Navbar; +// export default Navbar;