From d817ab02b00172e78b10fcab47b6bef1024579e1 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 4 May 2018 10:11:53 -0700 Subject: [PATCH] updated auth routes for login check and logout --- server/controllers/auth/logout/index.js | 6 +++++- server/controllers/auth/user/index.js | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/server/controllers/auth/logout/index.js b/server/controllers/auth/logout/index.js index 13d945b1..e79ee7c0 100644 --- a/server/controllers/auth/logout/index.js +++ b/server/controllers/auth/logout/index.js @@ -1,6 +1,10 @@ const logout = (req, res) => { req.logout(); - res.status(200).json({success: true, message: 'you successfully logged out'}); + const responseObject = { + success: true, + message: 'you successfully logged out' + }; + res.status(200).json(responseObject); }; module.exports = logout; diff --git a/server/controllers/auth/user/index.js b/server/controllers/auth/user/index.js index 9e776bbd..7cb1bdd0 100644 --- a/server/controllers/auth/user/index.js +++ b/server/controllers/auth/user/index.js @@ -1,9 +1,9 @@ const user = (req, res) => { - if (req.user) { - res.status(200).json({success: true, data: req.user}); - } else { - res.status(401).json({success: false, message: 'user is not logged in'}); - } + const responseObject = { + success: true, + data: req.user, + }; + res.status(200).json(responseObject); }; module.exports = user;