From 7f5eed2c4814cc673a9a381f9d68ac3346ae1a4e Mon Sep 17 00:00:00 2001
From: Martin Lehoux <martin@lehoux.net>
Date: Fri, 15 Feb 2019 22:21:22 +0100
Subject: [PATCH] bugs and linting

---
 models/notification.js | 19 ++++---------------
 models/user.js         | 25 +++++--------------------
 utils/notifications.js |  2 +-
 3 files changed, 10 insertions(+), 36 deletions(-)

diff --git a/models/notification.js b/models/notification.js
index f411cff..6a61815 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 993d4d7..5a7dfc7 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 0ff1738..7b40015 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
 };
 
-- 
GitLab