diff --git a/models/notification.js b/models/notification.js index f411cff6edcfea0b65353c5916ded00bd8c93aee..6a61815b60a38f680e0a5c149d6ab41914c0dde5 100644 --- a/models/notification.js +++ b/models/notification.js @@ -1,21 +1,10 @@ const mongoose = require('mongoose'); const Notification = new mongoose.Schema({ - title: { - type: String, - required: true, - }, - content: { - type: String, - }, - persistant: { - type: Boolean, - default: false, - }, - color: { - type: String, - default: "" - } + title: { type: String, required: true }, + content: { type: String }, + persistant: { type: Boolean, default: false }, + color: { type: String, default: "" } }); module.exports = Notification; \ No newline at end of file diff --git a/models/user.js b/models/user.js index 993d4d7ea91843c639a3ceb21a4680ca712b2280..5a7dfc7ff73e21fffbb02d6930774eebd9f6713f 100644 --- a/models/user.js +++ b/models/user.js @@ -2,26 +2,11 @@ const mongoose = require('mongoose'); const Notification = require('./notification'); const User = new mongoose.Schema({ - firstName: { - type: String, - required: true, - }, - lastName: { - type: String, - required: true, - }, - username: { - unique: true, - type: String, - lowercase: true, - }, - email: { - type: String, - required: true, - }, - passwordHash: { - type: String, - }, + firstName: { type: String, required: true }, + lastName: { type: String, required: true }, + username: { unique: true, type: String, lowercase: true }, + email: { type: String, required: true }, + passwordHash: { type: String }, notifications: [Notification], }); diff --git a/utils/notifications.js b/utils/notifications.js index 0ff17380fa82f573d1f51692539ab325f5cc8aba..7b4001590b46364828dbc253f776d488803f0cd3 100644 --- a/utils/notifications.js +++ b/utils/notifications.js @@ -5,7 +5,7 @@ const warn = (req, res, title, content) => { const error = (req, res, title, content) => { req.session.user.notifications.push({ title, content, color: "error" }); - req.user.session.save(); + req.session.user.save(); return res.redirect('/'); // TODO redirect to error route or previous };