From 2597172545f3fc6293ba57bd4ce959b4e2c039c0 Mon Sep 17 00:00:00 2001 From: RickyJary Date: Wed, 20 Nov 2024 17:55:33 +0100 Subject: [PATCH 1/7] starting iterations --- app.js | 4 +- controllers/auth.controller.js | 11 ++++ models/User.model.js | 37 ++++++++---- package.json | 1 + public/stylesheets/style.css | 104 ++++++++++++++++++++++++++++++++- routes/{index.js => router.js} | 4 ++ views/auth/signup.hbs | 23 ++++++++ 7 files changed, 169 insertions(+), 15 deletions(-) create mode 100644 controllers/auth.controller.js rename routes/{index.js => router.js} (62%) create mode 100644 views/auth/signup.hbs diff --git a/app.js b/app.js index 2ecc9f2220..53a5606592 100644 --- a/app.js +++ b/app.js @@ -25,8 +25,8 @@ const capitalized = string => string[0].toUpperCase() + string.slice(1).toLowerC app.locals.title = `${capitalized(projectName)}- Generated with Ironlauncher`; // 👇 Start handling routes here -const index = require('./routes/index'); -app.use('/', index); +const routes = require('./routes/router'); +app.use('/', routes); // ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes require('./error-handling')(app); diff --git a/controllers/auth.controller.js b/controllers/auth.controller.js new file mode 100644 index 0000000000..25997c0533 --- /dev/null +++ b/controllers/auth.controller.js @@ -0,0 +1,11 @@ +// routes/auth.routes.js + +const { Router } = require('express'); +const router = new Router(); + +// GET route ==> to display the signup form to users +module.exports.signUp = (req,res) => { + res.render('auth/signup') +} +// POST route ==> to process form data + diff --git a/models/User.model.js b/models/User.model.js index 9cdd3a3ce4..a307bb3bbd 100644 --- a/models/User.model.js +++ b/models/User.model.js @@ -1,14 +1,29 @@ -const { Schema, model } = require("mongoose"); +// models/User.model.js +const { Schema, model } = require('mongoose'); -// TODO: Please make sure you edit the user model to whatever makes sense in this case -const userSchema = new Schema({ - username: { - type: String, - unique: true +const userSchema = new Schema( + { + username: { + type: String, + trim: true, + required: [true, 'Username is required.'], + unique: true + }, + email: { + type: String, + required: [true, 'Email is required.'], + unique: true, + lowercase: true, + trim: true + }, + passwordHash: { + type: String, + required: [true, 'Password is required.'] + } }, - password: String -}); + { + timestamps: true + } +); -const User = model("User", userSchema); - -module.exports = User; +module.exports = model('User', userSchema); diff --git a/package.json b/package.json index 19489d9695..76f9de9da4 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "dev": "nodemon server.js" }, "dependencies": { + "bcryptjs": "^2.4.3", "cookie-parser": "^1.4.5", "dotenv": "^8.2.0", "express": "^4.17.1", diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 9453385b99..301783d551 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -1,8 +1,108 @@ +/* public/stylesheets/style.css */ body { padding: 50px; - font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; + font: 14px 'Lucida Grande', Helvetica, Arial, sans-serif; } a { - color: #00B7FF; + color: #00b7ff; + text-decoration: none; + font-size: 1.5em; +} + +form { + margin: 30px auto; + width: 380px; +} + +form label { + color: #666; + display: inline-block; + margin-bottom: 10px; + text-align: center; + width: 100%; +} + +form input, +form button { + box-sizing: border-box; + font-size: 14px; + outline: 0; + padding: 4px; + width: 100%; + margin-bottom: 20px; +} + +form button { + background: #43a3e6; + border: 1px solid #43a3e6; + border-radius: 4px; + color: #fff; + cursor: pointer; + display: inline-block; + font-size: 14px; + padding: 8px 16px; + text-decoration: none; + text-transform: uppercase; + transition: 0.3s ease background; + width: 100%; +} + +form button:hover { + background: #fff; + color: #43a3e6; + transition: 0.3s ease background; +} + +.error { + background: #f02b63; + box-sizing: border-box; + color: #fff; + margin: 20px auto; + padding: 20px; + width: 100%; +} + +ul { + border-bottom: 2px solid #43a3e6; + height: 30px; + padding: 1em 0; + list-style-type: none; +} + +ul li { + line-height: 20px; +} + +#to-right { + padding: 1em; + float: right; +} + +#to-right span { + color: #43a3e6; + font-size: 1.5em; +} + +#form h2 { + display: flex; + justify-content: center; +} + +#to-left { + float: left; +} + +#to-left p a { + color: #000; + font-weight: bold; + font-size: 2em; +} + +#logout-form { + display: inline; +} + +#logout-form button { + width: 120px; } diff --git a/routes/index.js b/routes/router.js similarity index 62% rename from routes/index.js rename to routes/router.js index 81c2396ceb..04c3b1f7bf 100644 --- a/routes/index.js +++ b/routes/router.js @@ -1,3 +1,5 @@ +const { signUp } = require("../controllers/auth.controller"); + const router = require("express").Router(); /* GET home page */ @@ -5,4 +7,6 @@ router.get("/", (req, res, next) => { res.render("index"); }); +router.get('/signup', signUp) + module.exports = router; diff --git a/views/auth/signup.hbs b/views/auth/signup.hbs new file mode 100644 index 0000000000..0433dc3e87 --- /dev/null +++ b/views/auth/signup.hbs @@ -0,0 +1,23 @@ +{{!-- views/auth/signup.hbs --}} + +
+

Signup

+
+ + + + + + + + + + {{!-- error message will be added here --}} +
+
From 8bf731c3606e3515e97e8c1ed40b41f5cfd360fc Mon Sep 17 00:00:00 2001 From: RickJary Date: Wed, 20 Nov 2024 21:33:38 +0100 Subject: [PATCH 2/7] restructuring --- controllers/auth.controller.js | 10 +++++++++- models/User.model.js | 28 ++++++++++++++++++++++++++-- package.json | 1 + routes/router.js | 3 ++- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/controllers/auth.controller.js b/controllers/auth.controller.js index 25997c0533..ef95ad4841 100644 --- a/controllers/auth.controller.js +++ b/controllers/auth.controller.js @@ -4,8 +4,16 @@ const { Router } = require('express'); const router = new Router(); // GET route ==> to display the signup form to users -module.exports.signUp = (req,res) => { +module.exports.signUp = (req, res, next) => { res.render('auth/signup') } + +module.exports.doSignUp = (req, res, next) => { + User.create(req.body) + .then((user) => { + user.checkPassword(req.body.passwordHash); + res.redirect("/") + }) +} // POST route ==> to process form data diff --git a/models/User.model.js b/models/User.model.js index a307bb3bbd..072bb4e5b2 100644 --- a/models/User.model.js +++ b/models/User.model.js @@ -1,5 +1,9 @@ // models/User.model.js const { Schema, model } = require('mongoose'); +const bcrypt = require("bcrypt"); + +const EMAIL_PATTERN = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; + const userSchema = new Schema( { @@ -14,7 +18,8 @@ const userSchema = new Schema( required: [true, 'Email is required.'], unique: true, lowercase: true, - trim: true + trim: true, + match: [EMAIL_PATTERN, "Email is invalid"] }, passwordHash: { type: String, @@ -26,4 +31,23 @@ const userSchema = new Schema( } ); -module.exports = model('User', userSchema); +userSchema.pre("save", function (next) { + const user = this; + if (user.isModified("passwordHash")) { + bcrypt.hash(user.passwordHash, 10) + .then((hash) => { + user.passwordHash = hash; + next(); + }) + } else { + next() + } +}); + +UserSchema.methods.checkPassword = function (password) { + return bcrypt.compare(password, this.password); +}; + +const User = mongoose.model("User", UserSchema); + +module.exports = User; diff --git a/package.json b/package.json index 76f9de9da4..858154faca 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "dev": "nodemon server.js" }, "dependencies": { + "bcrypt": "^5.1.1", "bcryptjs": "^2.4.3", "cookie-parser": "^1.4.5", "dotenv": "^8.2.0", diff --git a/routes/router.js b/routes/router.js index 04c3b1f7bf..e6c0239e4f 100644 --- a/routes/router.js +++ b/routes/router.js @@ -1,4 +1,4 @@ -const { signUp } = require("../controllers/auth.controller"); +const { signUp, doSignUp } = require("../controllers/auth.controller"); const router = require("express").Router(); @@ -8,5 +8,6 @@ router.get("/", (req, res, next) => { }); router.get('/signup', signUp) +router.post('/signup', doSignUp) module.exports = router; From e5daabd55c28cd6ccae6fe144bee4a186acbd176 Mon Sep 17 00:00:00 2001 From: RickyJary Date: Thu, 21 Nov 2024 16:30:11 +0100 Subject: [PATCH 3/7] signup but hash --- controllers/auth.controller.js | 22 +++++++++++++++++++++- models/User.model.js | 22 ++++++++++++++++++++++ routes/router.js | 7 ++++++- views/auth/signup.hbs | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/controllers/auth.controller.js b/controllers/auth.controller.js index 25997c0533..d7b3d82850 100644 --- a/controllers/auth.controller.js +++ b/controllers/auth.controller.js @@ -1,6 +1,7 @@ // routes/auth.routes.js - const { Router } = require('express'); +const User = require("../models/User.model") +const { default: mongoose } = require('mongoose'); const router = new Router(); // GET route ==> to display the signup form to users @@ -9,3 +10,22 @@ module.exports.signUp = (req,res) => { } // POST route ==> to process form data +module.exports.doSignUp = (req, res, next) => { + User.create(req.body) + .then((user) => { + user.checkPassword(req.body.passwordHash) + res.redirect("/login"); + }) + .catch((err) => { + if (err instanceof mongoose.Error.ValidationError) { + res.render("signup", { + user: { + email: req.body.email, + }, + errors: err.errors, + }); + } else { + next(err); + } + }) +} \ No newline at end of file diff --git a/models/User.model.js b/models/User.model.js index a307bb3bbd..d33e00a06f 100644 --- a/models/User.model.js +++ b/models/User.model.js @@ -1,6 +1,9 @@ // models/User.model.js const { Schema, model } = require('mongoose'); +const EMAIL_PATTERN = + /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; + const userSchema = new Schema( { username: { @@ -13,6 +16,7 @@ const userSchema = new Schema( type: String, required: [true, 'Email is required.'], unique: true, + match: [EMAIL_PATTERN, "Email is invalid"], lowercase: true, trim: true }, @@ -26,4 +30,22 @@ const userSchema = new Schema( } ); +userSchema.pre("save", function (next) { + const user = this; + + if (user.isModified("password")) { + bcrypt.hash(user.passwordHash, 10) + .then ((hash) => { + user.passwordHash = hash; + next(); + }); + } else { + next(); + } +}); + +userSchema.methods.checkPassword = function (password) { + return bcrypt.compare(password, this.passwordHash) +} + module.exports = model('User', userSchema); diff --git a/routes/router.js b/routes/router.js index 04c3b1f7bf..9dae991042 100644 --- a/routes/router.js +++ b/routes/router.js @@ -1,4 +1,8 @@ -const { signUp } = require("../controllers/auth.controller"); +const { + signUp, + doSignUp + +} = require("../controllers/auth.controller"); const router = require("express").Router(); @@ -8,5 +12,6 @@ router.get("/", (req, res, next) => { }); router.get('/signup', signUp) +router.post('/signup', doSignUp) module.exports = router; diff --git a/views/auth/signup.hbs b/views/auth/signup.hbs index 0433dc3e87..bd6db2275e 100644 --- a/views/auth/signup.hbs +++ b/views/auth/signup.hbs @@ -13,7 +13,7 @@ From e0391ee715dbbb29a010539038ee64a11d8cb5e8 Mon Sep 17 00:00:00 2001 From: RickyJary Date: Fri, 22 Nov 2024 11:28:01 +0100 Subject: [PATCH 4/7] iteration 1 and bonuses done --- controllers/auth.controller.js | 28 +++++++++++++++++++++++++++- models/User.model.js | 2 +- routes/router.js | 5 ++++- views/auth/logIn.hbs | 16 ++++++++++++++++ views/auth/signup.hbs | 4 ++-- 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 views/auth/logIn.hbs diff --git a/controllers/auth.controller.js b/controllers/auth.controller.js index 8d43b0cc02..7545e445d1 100644 --- a/controllers/auth.controller.js +++ b/controllers/auth.controller.js @@ -22,7 +22,7 @@ module.exports.doSignUp = (req, res, next) => { User.create(req.body) .then((user) => { user.checkPassword(req.body.passwordHash) - res.redirect("/login"); + res.redirect("/logIn"); }) .catch((err) => { if (err instanceof mongoose.Error.ValidationError) { @@ -36,4 +36,30 @@ module.exports.doSignUp = (req, res, next) => { next(err); } }) +} + +module.exports.logIn = (req, res, next) => { + res.render("auth/logIn") +} + +module.exports.doLogIn = (req, res, next) => { + const { email, passwordHash } = req.body; + User.findOne({ email }) + .then((user) => { + if(!user) { + res.redirect("/logIn"); + } else { + user.checkPassword(passwordHash) + .then((match) => { + if(match) { + res.redirect("/profile"); + } else { + res.redirect("/logIn") + } + }) + } + }) + .catch((err) => { + console.error(err) + }) } \ No newline at end of file diff --git a/models/User.model.js b/models/User.model.js index d9093f977b..714692de66 100644 --- a/models/User.model.js +++ b/models/User.model.js @@ -34,7 +34,7 @@ const userSchema = new Schema( userSchema.pre("save", function (next) { const user = this; - if (user.isModified("password")) { + if (user.isModified("passwordHash")) { bcrypt.hash(user.passwordHash, 10) .then ((hash) => { user.passwordHash = hash; diff --git a/routes/router.js b/routes/router.js index e6c0239e4f..1b95f56730 100644 --- a/routes/router.js +++ b/routes/router.js @@ -1,4 +1,4 @@ -const { signUp, doSignUp } = require("../controllers/auth.controller"); +const { signUp, doSignUp, logIn, doLogIn } = require("../controllers/auth.controller"); const router = require("express").Router(); @@ -10,4 +10,7 @@ router.get("/", (req, res, next) => { router.get('/signup', signUp) router.post('/signup', doSignUp) +router.get('/logIn', logIn) +router.post('/logIn', doLogIn) + module.exports = router; diff --git a/views/auth/logIn.hbs b/views/auth/logIn.hbs new file mode 100644 index 0000000000..b34c5ef905 --- /dev/null +++ b/views/auth/logIn.hbs @@ -0,0 +1,16 @@ +
+

LogIn

+
+ + + + + + + +
+
diff --git a/views/auth/signup.hbs b/views/auth/signup.hbs index bd6db2275e..01be5b160d 100644 --- a/views/auth/signup.hbs +++ b/views/auth/signup.hbs @@ -9,11 +9,11 @@ From 5fec1a5b66df0fdfb1f51f5eac990526a439f9b6 Mon Sep 17 00:00:00 2001 From: RickyJary Date: Fri, 22 Nov 2024 11:31:37 +0100 Subject: [PATCH 5/7] fixed iteration 1 and bonuses done --- controllers/auth.controller.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/controllers/auth.controller.js b/controllers/auth.controller.js index 7545e445d1..168922ca13 100644 --- a/controllers/auth.controller.js +++ b/controllers/auth.controller.js @@ -9,13 +9,7 @@ module.exports.signUp = (req, res, next) => { res.render('auth/signup') } -module.exports.doSignUp = (req, res, next) => { - User.create(req.body) - .then((user) => { - user.checkPassword(req.body.passwordHash); - res.redirect("/") - }) -} + // POST route ==> to process form data module.exports.doSignUp = (req, res, next) => { From f6117924cebaa1235f49443c215dda3d83509f2c Mon Sep 17 00:00:00 2001 From: RickJary Date: Sat, 23 Nov 2024 13:59:26 +0100 Subject: [PATCH 6/7] iterations done --- app.js | 18 +++++++++++++++ config/session.config.js | 41 ++++++++++++++++++++++++++++++++++ controllers/auth.controller.js | 28 ++++++++++++++++------- controllers/user.controller.js | 13 +++++++++++ middlewares/auth.middleware.js | 15 +++++++++++++ package.json | 2 ++ routes/router.js | 20 ++++++++++++----- views/layout.hbs | 20 ++++++++++++----- views/main.hbs | 1 + views/partials/nav.hbs | 39 ++++++++++++++++++++++++++++++++ views/private.hbs | 3 +++ views/users/profile.hbs | 5 +++++ 12 files changed, 185 insertions(+), 20 deletions(-) create mode 100644 config/session.config.js create mode 100644 controllers/user.controller.js create mode 100644 middlewares/auth.middleware.js create mode 100644 views/main.hbs create mode 100644 views/partials/nav.hbs create mode 100644 views/private.hbs create mode 100644 views/users/profile.hbs diff --git a/app.js b/app.js index 53a5606592..697add6c27 100644 --- a/app.js +++ b/app.js @@ -5,16 +5,32 @@ require('dotenv/config'); // ℹ️ Connects to the database require('./db'); +const { sessionConfig, loggedUser } = require("./config/session.config") + + // Handles http requests (express is node js framework) // https://www.npmjs.com/package/express const express = require('express'); // Handles the handlebars // https://www.npmjs.com/package/hbs +const path = require("path"); const hbs = require('hbs'); const app = express(); +app.use(express.json()); +app.use(express.urlencoded({ extended: false })); + +// Normalizes the path to the views folder +app.set("views", path.join(__dirname, "views")); +// Sets the view engine to handlebars +app.set("view engine", "hbs"); +// Handles access to the public folder +app.use(express.static(path.join(__dirname, "public"))); + +hbs.registerPartials(__dirname + "/views/partials"); + // ℹ️ This function is getting exported from the config folder. It runs most middlewares require('./config')(app); @@ -25,6 +41,8 @@ const capitalized = string => string[0].toUpperCase() + string.slice(1).toLowerC app.locals.title = `${capitalized(projectName)}- Generated with Ironlauncher`; // 👇 Start handling routes here +app.use(sessionConfig); +app.use(loggedUser) const routes = require('./routes/router'); app.use('/', routes); diff --git a/config/session.config.js b/config/session.config.js new file mode 100644 index 0000000000..3d082e9376 --- /dev/null +++ b/config/session.config.js @@ -0,0 +1,41 @@ +const User = require("../models/User.model"); +const expressSession = require("express-session"); +const MongoStore = require("connect-mongo"); +const mongoose = require("mongoose"); + +const MAX_AGE = 7; + +module.exports.sessionConfig = expressSession({ + name: "express-coookie", + secret: "super-secret", + resave: false, + saveUninitialized: false, + cookie: { + secure: false, + httpOnly: true, + maxAge: 24 * 3600 * 1000 * MAX_AGE, + }, + store: new MongoStore({ + mongoUrl: mongoose.connection._connectionString, + ttl: 24 * 3600 * MAX_AGE, + }), +}); + +module.exports.loggedUser = (req, res, next) => { + const userId = req.session.userId; + if (userId) { + User.findById(userId) + .then((userFound) => { + if (userFound) { + req.currentUser = userFound; + res.locals.currentUser = userFound; + next(); + } else { + next(); + } + }) + .catch((err) => next(err)); + } else { + next(); + } +}; diff --git a/controllers/auth.controller.js b/controllers/auth.controller.js index 168922ca13..cd3b2b119e 100644 --- a/controllers/auth.controller.js +++ b/controllers/auth.controller.js @@ -38,22 +38,34 @@ module.exports.logIn = (req, res, next) => { module.exports.doLogIn = (req, res, next) => { const { email, passwordHash } = req.body; + + const renderWithErrors = () => { + res.render("auth/login", { + email, + error: "Email o constraseña incorrectos" + }) + } User.findOne({ email }) .then((user) => { - if(!user) { - res.redirect("/logIn"); - } else { - user.checkPassword(passwordHash) + if(user) { + return user.checkPassword(passwordHash) .then((match) => { if(match) { + req.session.userId = user.id; res.redirect("/profile"); } else { - res.redirect("/logIn") + renderWithErrors(); } }) + } else { + renderWithErrors(); } }) - .catch((err) => { - console.error(err) - }) + .catch((err) => next(err)) +} + +module.exports.logOut = (req, res, next) => { + req.session.destroy(); + res.clearCookie("express-cookie"); + res.redirect("/login") } \ No newline at end of file diff --git a/controllers/user.controller.js b/controllers/user.controller.js new file mode 100644 index 0000000000..8a3420b8c9 --- /dev/null +++ b/controllers/user.controller.js @@ -0,0 +1,13 @@ +const User = require("../models/User.model"); + +module.exports.profile = (req, res, next) => { + res.render("users/profile") +} + +module.exports.funnyCat = (req, res, next) => { + res.render("main") +} + +module.exports.private = (req, res, next) => { + res.render("private") +} \ No newline at end of file diff --git a/middlewares/auth.middleware.js b/middlewares/auth.middleware.js new file mode 100644 index 0000000000..53d1119b79 --- /dev/null +++ b/middlewares/auth.middleware.js @@ -0,0 +1,15 @@ +module.exports.isAuthenticated = (req, res, next) => { + if(req.currentUser) { + next(); + } else { + res.redirect("/logIn") + } +} + +module.exports.isNotAuthenticated = (req, res, next) => { + if(!req.currentUser) { + next(); + } else { + res.redirect("/profile") + } +} \ No newline at end of file diff --git a/package.json b/package.json index 858154faca..7a08f67ec8 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,11 @@ "dependencies": { "bcrypt": "^5.1.1", "bcryptjs": "^2.4.3", + "connect-mongo": "^5.1.0", "cookie-parser": "^1.4.5", "dotenv": "^8.2.0", "express": "^4.17.1", + "express-session": "^1.18.1", "hbs": "^4.1.1", "mongoose": "^6.1.2", "morgan": "^1.10.0", diff --git a/routes/router.js b/routes/router.js index 1b95f56730..330a3b66ed 100644 --- a/routes/router.js +++ b/routes/router.js @@ -1,5 +1,6 @@ -const { signUp, doSignUp, logIn, doLogIn } = require("../controllers/auth.controller"); - +const { signUp, doSignUp, logIn, doLogIn, logOut } = require("../controllers/auth.controller"); +const { profile, funnyCat, private } = require("../controllers/user.controller") +const { isAuthenticated, isNotAuthenticated } = require("../middlewares/auth.middleware") const router = require("express").Router(); /* GET home page */ @@ -7,10 +8,17 @@ router.get("/", (req, res, next) => { res.render("index"); }); -router.get('/signup', signUp) -router.post('/signup', doSignUp) +router.get('/signup', isNotAuthenticated, signUp) +router.post('/signup', isNotAuthenticated, doSignUp) + +router.get('/logIn', isNotAuthenticated, logIn) +router.post('/logIn', isNotAuthenticated, doLogIn) + +router.get('/profile', isAuthenticated, profile) + +router.get('/main', isAuthenticated, funnyCat) +router.get('/private', isAuthenticated, private) -router.get('/logIn', logIn) -router.post('/logIn', doLogIn) +router.get('/logout', logOut) module.exports = router; diff --git a/views/layout.hbs b/views/layout.hbs index 73199c166b..308b0a0e49 100644 --- a/views/layout.hbs +++ b/views/layout.hbs @@ -1,19 +1,27 @@ + - - - + + + {{title}} + + - - {{{body}}} + {{> nav}} +
+ {{{body}}} +
- \ No newline at end of file + diff --git a/views/main.hbs b/views/main.hbs new file mode 100644 index 0000000000..0d4d058ca6 --- /dev/null +++ b/views/main.hbs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/partials/nav.hbs b/views/partials/nav.hbs new file mode 100644 index 0000000000..35987873ec --- /dev/null +++ b/views/partials/nav.hbs @@ -0,0 +1,39 @@ + diff --git a/views/private.hbs b/views/private.hbs new file mode 100644 index 0000000000..a5067509e4 --- /dev/null +++ b/views/private.hbs @@ -0,0 +1,3 @@ +

THIS IS A PRIVATE PAGE FOR {{currentUser.username}}

+ + \ No newline at end of file diff --git a/views/users/profile.hbs b/views/users/profile.hbs new file mode 100644 index 0000000000..9917a48125 --- /dev/null +++ b/views/users/profile.hbs @@ -0,0 +1,5 @@ +

PROFILE

+ +
+

{{currentUser.email}}

+
From 338b46c6656a25fd054ed7fd62cdb6dd5ebaee99 Mon Sep 17 00:00:00 2001 From: RickJary Date: Sat, 23 Nov 2024 14:02:20 +0100 Subject: [PATCH 7/7] cookie name fixed --- config/session.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/session.config.js b/config/session.config.js index 3d082e9376..c71b59425d 100644 --- a/config/session.config.js +++ b/config/session.config.js @@ -6,7 +6,7 @@ const mongoose = require("mongoose"); const MAX_AGE = 7; module.exports.sessionConfig = expressSession({ - name: "express-coookie", + name: "express-cookie", secret: "super-secret", resave: false, saveUninitialized: false,