Skip to content

Commit

Permalink
Issue #7: Lay out and explain file structure
Browse files Browse the repository at this point in the history
- Move auth code to middleware folder
- The auth code runs as middleware
  • Loading branch information
codebru committed Jul 18, 2019
1 parent facf99d commit 7d6aa26
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Components/User/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* INCLUDES ****************************** */
const express = require('express');
const passport = require('passport');
const { isAlreadyAuthenticated } = require('./../../Utils/Passport/auth');
const { isAlreadyAuthenticated } = require('../../Middleware/Passport/auth');
/* **************************************** */

/* ROUTES ********************************* */
Expand Down
1 change: 1 addition & 0 deletions Utils/Passport/auth.js → Middleware/Passport/auth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* AUTH FUNCTIONS ************************* */
function isAuthenticated(req, res, next) {
// TODO change names of these funtions as they clash with the req.blah name
if (req.isAuthenticated()) {
next();
return;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const passport = require('passport');
const flash = require('flash');
const bodyParser = require('body-parser');
const dotenv = require('dotenv');
const passportConfig = require('./Utils/Passport/config');
const passportConfig = require('./Middleware/Passport/config');
/* **************************************** */

/* INCLUDE CONFIGS ************************ */
Expand Down

0 comments on commit 7d6aa26

Please sign in to comment.