diff --git a/auth/middleware/auth.js b/auth/middleware/auth.js index d22ae5b..b8578d1 100644 --- a/auth/middleware/auth.js +++ b/auth/middleware/auth.js @@ -1,4 +1,5 @@ const jwt = require("jsonwebtoken"); +const config = require("config"); const auth = (req, res, next) => { try { @@ -8,7 +9,7 @@ const auth = (req, res, next) => { .status(401) .json({ msg: "No authentication token, authorization denied." }); - const verified = jwt.verify(token, process.env.JWT_SECRET); + const verified = jwt.verify(token, config.get("jwtSecret") ); if (!verified) return res .status(401) diff --git a/auth/routes/users.js b/auth/routes/users.js index 185fac0..d952d85 100644 --- a/auth/routes/users.js +++ b/auth/routes/users.js @@ -5,13 +5,6 @@ const auth = require("../middleware/auth"); const User = require("../schemas/User"); const config = require("config"); -router.get("/", async(req,res) => { - - console.log(config.get('jwtSecret')); - return "

asdf

"; - - -}); router.post("/register", async (req, res) => { try { @@ -68,8 +61,8 @@ router.post("/login", async (req, res) => { if (!isMatch) return res.status(400).json({ msg: "Invalid credentials." }); const token = jwt.sign({ id: user._id },config.get('jwtSecret')); - if(token) return res.json - res.json({ + if(token) return res + .json({ token, user: { id: user._id, @@ -93,14 +86,14 @@ router.delete("/delete", auth, async (req, res) => { router.post("/tokenIsValid", async (req, res) => { try { const token = req.header("x-auth-token"); - if (!token) return res.json({error: qwer}); + if (!token) return res.json({error: message}); const verified = jwt.verify(token, config.get("jwtSecret")); - if (!verified) return res.json({error: asdf}); + if (!verified) return res.json({error: message}); const user = await User.findById(verified.id); - if (!user) return res.json({error: zxcv}); + if (!user) return res.json({error: message}); return res.json(true); } catch (err) { @@ -110,6 +103,7 @@ router.post("/tokenIsValid", async (req, res) => { router.get("/", auth, async (req, res) => { const user = await User.findById(req.user); + console.log(user); res.json({ username: user.username, id: user._id, diff --git a/src/App.js b/src/App.js index 49f0be7..743e7b9 100644 --- a/src/App.js +++ b/src/App.js @@ -3,10 +3,11 @@ import Axios from 'axios'; import HomePage from "./components/HomePage"; import PricingPlan from "./components/PricingPlan"; import LogInContainer from "./components/LogInContainer"; -import { Router,BrowserRouter, Route, Switch } from 'react-router-dom'; +import { BrowserRouter, Route, Switch } from 'react-router-dom'; import UserContext from "./context/UserContext"; import Options from "./components/Options"; import Stepper from './components/Stepper'; +import NavBar from "./components/NavBar"; export default function App() { const [userData, setUserData ] = useState({ @@ -43,21 +44,25 @@ export default function App() { },[]) return ( + <>
+ +
404
}/>
+ ); } diff --git a/src/components/ErrorNotice.js b/src/components/ErrorNotice.js index 6204dd9..9391e37 100644 --- a/src/components/ErrorNotice.js +++ b/src/components/ErrorNotice.js @@ -1,10 +1,34 @@ import React from "react"; +import styled from 'styled-components'; + export default function ErrorNotice(props) { + const ErrorNotice = styled.div` + margin: 1rem 0; + padding: 0.5rem; + border: 1px solid #e07c7c; + border-radius: 8px; + display: flex; + justify-content: space-between; + align-items: center; + background-color: #f8d6d6; +`; + const ErrorMessage = styled.div` +color: #000000; +`; + + const ErrorButton = styled.button + ` + width: 17px; + height: 28px; + display:flex; + background-color: #df4343; + color: #ffffff; +`; return ( -
- {props.message} - -
+ + {props.message} + x + ); } \ No newline at end of file diff --git a/src/components/HomePage.js b/src/components/HomePage.js index 25edd98..d0c0fe4 100644 --- a/src/components/HomePage.js +++ b/src/components/HomePage.js @@ -1,13 +1,13 @@ -import React, { Component } from 'react'; +import React from 'react'; import '../homepage.css'; -import LogInContainer from './LogInContainer'; import 'bootstrap/dist/css/bootstrap.min.css'; -import Navbar from './NavBar'; import NavBar from './NavBar'; +import { useHistory } from "react-router-dom"; -class HomePage extends Component { - render(){ +export default function HomePage(){ + const history = useHistory(); + return (
@@ -21,9 +21,11 @@ class HomePage extends Component {

Adapt to a new place easy peasy.

- + - +
@@ -162,6 +164,4 @@ class HomePage extends Component { ); } -} -export default HomePage; \ No newline at end of file diff --git a/src/components/LogInContainer.js b/src/components/LogInContainer.js index b4fc1ab..8b62b24 100644 --- a/src/components/LogInContainer.js +++ b/src/components/LogInContainer.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { BrowserRouter, Route, NavLink, Switch } from 'react-router-dom'; +import { BrowserRouter, Route, NavLink, Switch,withRouter } from 'react-router-dom'; import Register from './Register'; import Login from './Login'; @@ -37,5 +37,5 @@ class LogInContainer extends Component { } } -export default LogInContainer; +export default withRouter(LogInContainer); diff --git a/src/components/Login.js b/src/components/Login.js index bf24e63..17f1be0 100644 --- a/src/components/Login.js +++ b/src/components/Login.js @@ -1,10 +1,9 @@ import React, { useState, useContext } from "react"; -import { useHistory } from "react-router-dom"; import UserContext from "../context/UserContext"; import Axios from "axios"; -import { Link } from "react-router-dom"; import ErrorNotice from "./ErrorNotice"; +import { Link, useHistory, withRouter } from "react-router-dom"; const Login = () => { @@ -12,7 +11,7 @@ const Login = () => { const [password, setPassword] = useState(); const [error, setError] = useState(); - const { setUserData } = useContext(UserContext); + const { userData,setUserData } = useContext(UserContext); const history = useHistory(); @@ -24,13 +23,13 @@ const Login = () => { "http://localhost:5000/users/login", loginUser ); - console.log(loginRes); setUserData({ token: loginRes.data.token, user: loginRes.data.user, }); localStorage.setItem("auth-token", loginRes.data.token); - history.push("/register"); + console.log(userData); + history.push("/"); } catch (err) { err.response.data.msg && setError(err.response.data.msg); } @@ -38,6 +37,9 @@ const Login = () => { return (
+ {error && ( + setError(undefined)} /> + )}
@@ -53,11 +55,9 @@ const Login = () => { Not a member?
- {error && ( - setError(undefined)} /> - )} +
); } -export default Login; \ No newline at end of file +export default withRouter(Login); \ No newline at end of file diff --git a/src/components/NavBar.js b/src/components/NavBar.js index e75fcc0..6c55b8d 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -1,16 +1,13 @@ -import React, { useState, useEffect, useContext } from 'react'; -import { useHistory } from "react-router-dom"; +import React, { useContext } from 'react'; +import { Link } from "react-router-dom"; import '../navbar.css'; -import Axios from "axios"; import UserContext from "../context/UserContext"; export default function NavBar() { const { userData, setUserData } = useContext(UserContext); + - const history = useHistory(); - const register = () => history.push("/user/register"); - const login = () => history.push("/home"); const logout = () => { setUserData({ token: undefined, @@ -33,18 +30,18 @@ export default function NavBar() { - locaft + locaft diff --git a/src/components/Register.js b/src/components/Register.js index 0c7d3f5..4d439d9 100644 --- a/src/components/Register.js +++ b/src/components/Register.js @@ -1,4 +1,4 @@ -import React, { Component, useState, useContext } from "react"; +import React, { useState, useContext } from "react"; import { useHistory } from "react-router-dom"; import UserContext from "../context/UserContext"; import Axios from "axios"; @@ -87,7 +87,7 @@ import ErrorNotice from "./ErrorNotice";
diff --git a/src/components/Stepper.js b/src/components/Stepper.js index c576917..5388a3d 100644 --- a/src/components/Stepper.js +++ b/src/components/Stepper.js @@ -1,51 +1,46 @@ -import React, {useState} from 'react'; -import styles from '../stepper.module.css'; -import classNames from 'classnames'; +import React from 'react'; +import '../stepper.css'; export default function Stepper() { - const[next,setNext] = useState(false); - const[clear,setClear] = useState(false); - document.addEventListener('DOMContentLoaded', () => { var list = document.getElementById('progress'), - next = document.getElementById('next'), - clear = document.getElementById('clear'), - children = [...document.querySelectorAll('ele')], - completed = 0; - console.log(children); - - // simulate activating a node - if(next === true){ - - // count the number of completed nodes. - completed = (completed === 0) ? 1 : completed + 2; - if (completed > children.length) return; - - // for each node that is completed, reflect the status - // and show a green color! - for (var i = 0; i < completed; i++) { - children[i].children[0].classNameList.remove(styles['grey']); - children[i].children[0].classNameList.add(styles['green']); + next = document.getElementById('next'), + clear = document.getElementById('clear'), + children = list.children, + completed = 0; +// simulate activating a node +next.addEventListener('click', function() { + + // count the number of completed nodes. + completed = (completed === 0) ? 1 : completed + 2; + if (completed > children.length) return; + + // for each node that is completed, reflect the status + // and show a green color! + for (var i = 0; i < completed; i++) { + children[i].children[0].classList.remove('grey'); + children[i].children[0].classList.add('green'); + // if this child is a node and not divider, // make it shine a little more if (i % 2 === 0) { - children[i].children[0].classNameList.add('activated'); + children[i].children[0].classList.add('activated'); } - } - } + +}, false); - // clear the activated state of the markers - if(clear === true){ - for (var i = 0; i < children.length; i++) { - children[i].children[0].classNameList.remove('green'); - children[i].children[0].classNameList.remove('activated'); - children[i].children[0].classNameList.add('grey'); - } - completed = 0; +// clear the activated state of the markers +clear.addEventListener('click', function() { + for (var i = 0; i < children.length; i++) { + children[i].children[0].classList.remove('green'); + children[i].children[0].classList.remove('activated'); + children[i].children[0].classList.add('grey'); } + completed = 0; +}, false); }); return ( @@ -55,16 +50,16 @@ export default function Stepper() {

- setNext(true)} value="Next" id="next" /> - setNext(true)} value="Clear" id="clear" /> + +
) diff --git a/src/homepage.css b/src/homepage.css index 999ebea..5d3e551 100644 --- a/src/homepage.css +++ b/src/homepage.css @@ -6,6 +6,11 @@ div { h1, h2, h3, h4, h5, h6 { font-family: "Montserrat-Bold"; + color: white; + +} +h1 { + color: white !important; } p { @@ -51,31 +56,7 @@ p { } /* Navigation Bar */ -.header{ - position:sticky; - top:0; -} -.navbar { - padding: 0 0 4.5rem; - position: sticky; - top: 0; -} - -.navbar-brand { - font-family: "Ubuntu"; - font-size: 2.5rem; - font-weight: bold; -} - -.nav-item { - padding: 0 18px; -} - -.nav-link { - font-size: 1.2rem; - font-family: "Montserrat-Light"; -} /* Buttons */ @@ -192,11 +173,3 @@ p { } } -/* Login Page */ - -.login-heading{ - margin: 3% 5%; -} -.signup .signin{ - margin: 10% 3%; -} \ No newline at end of file diff --git a/src/stepper.module.css b/src/stepper.css similarity index 87% rename from src/stepper.module.css rename to src/stepper.css index 3ecfe77..4d133c8 100644 --- a/src/stepper.module.css +++ b/src/stepper.css @@ -1,6 +1,5 @@ *, *:after, *:before { margin:0; padding:0; } body { - padding: 15px; font-family: Helvetica, sans-serif; }