add verification of email on staffs

This commit is contained in:
Guillermo Giuliana 2021-12-23 22:23:05 -03:00
parent fe1dd1bd48
commit bfb7256400
1 changed files with 18 additions and 1 deletions

View File

@ -85,7 +85,11 @@ class EditStaffController extends Controller {
private function editInformation() {
if(Controller::request('email')) {
$this->staffInstance->email = Controller::request('email');
$newEmail = Controller::request('email');
$this->verifyEmail($newEmail);
$this->staffInstance->email = $newEmail;
}
if(Controller::request('password')) {
@ -131,7 +135,20 @@ class EditStaffController extends Controller {
$this->staffInstance->store();
}
private function verifyEmail($email){
$staff = Staff::getDataStore($email,'email');
$user = User::getDataStore($email,'email');
if($user->email == $email){
throw new RequestException(ERRORS::INVALID_EMAIL);
}
if($staff->email == $email && $this->staffInstance->email != $email){
throw new RequestException(ERRORS::INVALID_EMAIL);
}
}
private function getDepartmentList() {
$listDepartments = new DataStoreList();
$departmentIds = json_decode(Controller::request('departments'));