Compare commits
No commits in common. "ce7be33a67ceb67a072bc585c7f08bda23dcfd2c" and "bd8a03d72f7c5bf9b2300a811d91f60f7b9d8cad" have entirely different histories.
ce7be33a67
...
bd8a03d72f
|
|
@ -33,14 +33,17 @@ module.exports.post = async function(req, res){
|
|||
const data = matchedData(req);
|
||||
|
||||
//make sure we're not bullshitting ourselves here.
|
||||
if(user == null || user.user == null){
|
||||
return errorHandler(res, 'You must be logged in to delete your account!', 'unauthorized');
|
||||
if(user == null){
|
||||
res.status(400);
|
||||
return res.send('Invalid Session! Cannot delete account while logged out!');
|
||||
}
|
||||
|
||||
const userDB = await userModel.findOne({user: user.user});
|
||||
|
||||
|
||||
if(!userDB){
|
||||
return errorHandler(res, 'User not found!', 'unauthorized');
|
||||
res.status(400);
|
||||
return res.send('Invalid User! Account must exist in order to delete!');
|
||||
}
|
||||
|
||||
await userDB.nuke(data.pass);
|
||||
|
|
|
|||
|
|
@ -46,12 +46,6 @@ module.exports.post = async function(req, res){
|
|||
const {field, change} = data;
|
||||
const {user} = req.session;
|
||||
|
||||
//If the user is null
|
||||
if(user == null || user.user == null){
|
||||
//BEFORE YOU BREAK MY HEART!!!
|
||||
return errorHandler(res, 'You must be logged in to preform this action!', 'unauthorized');
|
||||
}
|
||||
|
||||
const userDB = await userModel.findOne({user: user.user});
|
||||
const update = {};
|
||||
|
||||
|
|
@ -92,7 +86,8 @@ module.exports.post = async function(req, res){
|
|||
res.status(200);
|
||||
return res.send(update);
|
||||
}else{
|
||||
return errorHandler(res, 'User not found!', 'unauthorized');
|
||||
res.status(400);
|
||||
return res.send({errors: [{msg:"User not found!"}]});
|
||||
}
|
||||
}else{
|
||||
res.status(400);
|
||||
|
|
|
|||
Loading…
Reference in a new issue