Validate username password type when logging in, and validate email when reseting password (#2679)
* Validate username password type when logging in, and validate email when reset password * Add test for validation
This commit is contained in:
committed by
Florent Vilmart
parent
eb1cfcf351
commit
58a2ee32fa
@@ -79,6 +79,9 @@ export class UsersRouter extends ClassesRouter {
|
||||
if (!req.body.password) {
|
||||
throw new Parse.Error(Parse.Error.PASSWORD_MISSING, 'password is required.');
|
||||
}
|
||||
if (typeof req.body.username !== 'string' || typeof req.body.password !== 'string') {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Invalid username/password.');
|
||||
}
|
||||
|
||||
let user;
|
||||
let isValidPassword = false;
|
||||
@@ -190,6 +193,9 @@ export class UsersRouter extends ClassesRouter {
|
||||
if (!email) {
|
||||
throw new Parse.Error(Parse.Error.EMAIL_MISSING, "you must provide an email");
|
||||
}
|
||||
if (typeof email !== 'string') {
|
||||
throw new Parse.Error(Parse.Error.INVALID_EMAIL_ADDRESS, 'you must provide a valid email string');
|
||||
}
|
||||
let userController = req.config.userController;
|
||||
return userController.sendPasswordResetEmail(email).then(token => {
|
||||
return Promise.resolve({
|
||||
|
||||
Reference in New Issue
Block a user