fix bug #288 and add validatios

This commit is contained in:
Guillermo 2018-09-05 01:21:21 -03:00
parent 20fbfa1e05
commit e43835b2bc
2 changed files with 17 additions and 3 deletions

View File

@ -290,7 +290,7 @@ class StaffEditor extends React.Component {
API.call({
path: '/staff/edit',
data: {
staffId: this.props.staffId,
staffId: (!this.props.myAccount) ? this.props.staffId : null,
sendEmailOnNewTicket: (eventType === 'SEND_EMAIL_ON_NEW_TICKET') ? form.sendEmailOnNewTicket * 1 : null,
email: (eventType === 'EMAIL') ? form.email : null,
password: (eventType === 'PASSWORD') ? form.password : null,

View File

@ -36,7 +36,21 @@ class EditStaffController extends Controller {
public function validations() {
return [
'permission' => 'staff_1',
'requestData' => []
'requestData' => [
'email' => [
'validation' => DataValidator::oneOf(DataValidator::email(), DataValidator::falseVal()),
'error' => ERRORS::INVALID_EMAIL
],
'password' => [
'validation' => DataValidator::oneOf(DataValidator::length(5, 200), DataValidator::falseVal()),
'error' => ERRORS::INVALID_PASSWORD
],
'level' => [
'validation' => DataValidator::oneOf(DataValidator::between(1, 3, true), DataValidator::falseVal()),
'error' => ERRORS::INVALID_LEVEL
]
]
];
}
@ -53,7 +67,7 @@ class EditStaffController extends Controller {
return;
}
} else {
Response::respondError(ERRORS::NO_PERMISSION);
Response::respondError($staffId);
return;
}