updated auth routes for login check and logout
This commit is contained in:
parent
52f2416d88
commit
d817ab02b0
2 changed files with 10 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue