Skip to content

Commit

Permalink
cleaned the code and edited some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabcodingzest committed Aug 22, 2020
1 parent 1de1b1f commit 9312afe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
9 changes: 1 addition & 8 deletions routes/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const express = require("express");
const passport = require("passport");
const router = express.Router();
const { ensureGuest } = require("../../middleware/auth");

// @desc Auth with Google
// @route GET /auth/google
Expand All @@ -21,14 +22,6 @@ router.get(
}
);

router.post('/signin', (req, res, next) => {
passport.authenticate('local', {
successRedirect: '/portfolio',
failureRedirect: '/',
failureFlash: true
})(req, res, next)
})

// @desc Logout user
// @route /auth/logout
router.get("/logout", (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion routes/api/market.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const totalData = require("../../config/data-total.json");

// @desc Market page
// @route GET /Market
// @access Privat
// @access Private
router.get("/", ensureAuth, async (req, res) => {
let min = 0;
let max = 75;
Expand Down
5 changes: 3 additions & 2 deletions routes/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ router.get('/signup', ensureGuest, (req, res) => {

// @desc Submit Sign Up Form
// @route GET /user/signup
router.post('/signup', (req, res) => {
// @access Public
router.post('/signup', ensureGuest, (req, res) => {
const { firstName, lastName, password1, password2, email } = req.body;
let errors = [];

Expand Down Expand Up @@ -67,7 +68,7 @@ router.post('/signup', (req, res) => {

// @desc Submit Sign In Form
// @route GET /user/signin
router.post('/signin', (req, res, next) => {
router.post('/signin', ensureGuest, (req, res, next) => {
passport.authenticate('local', {
successRedirect: '/portfolio',
failureRedirect: '/',
Expand Down

0 comments on commit 9312afe

Please sign in to comment.