mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 10:18:48 +00:00
Finished fixing login and signup backend.
This commit is contained in:
parent
c5bec46b52
commit
eb945fa0cf
@ -15,7 +15,7 @@ exports.signup = (req, res) => {
|
||||
handle: req.body.handle,
|
||||
password: req.body.password,
|
||||
confirmPassword: req.body.confirmPassword,
|
||||
time: new Date().toISOString()
|
||||
createdAt: new Date().toISOString()
|
||||
};
|
||||
|
||||
// console.log(newUser);
|
||||
@ -76,7 +76,7 @@ exports.signup = (req, res) => {
|
||||
const userCred = {
|
||||
email: req.body.email,
|
||||
handle: newUser.handle,
|
||||
time: newUser.time,
|
||||
createdAt: newUser.createdAt,
|
||||
userId
|
||||
}
|
||||
return db.doc(`/users/${newUser.handle}`).set(userCred);
|
||||
@ -100,20 +100,20 @@ exports.login = (req, res) => {
|
||||
}
|
||||
|
||||
//Auth validation
|
||||
let invalidCred = {};
|
||||
let errors = {};
|
||||
|
||||
//Email check
|
||||
if(user.email.trim() === '') {
|
||||
invalidCred.email = 'Email must not be blank.';
|
||||
errors.email = 'Email must not be blank.';
|
||||
}
|
||||
|
||||
//Password check
|
||||
if(user.password.trim() === '') {
|
||||
invalidCred.password = 'Password must not be blank.';
|
||||
errors.password = 'Password must not be blank.';
|
||||
}
|
||||
|
||||
//Overall check
|
||||
if(Object.keys(invalidCred).length > 0) {
|
||||
if(Object.keys(errors).length > 0) {
|
||||
return res.status(400).json(errors);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user