add email verification users
This commit is contained in:
parent
bfb7256400
commit
edfac8f3b2
|
@ -42,7 +42,11 @@ class EditEmail extends Controller{
|
|||
$newEmail = Controller::request('newEmail');
|
||||
$user = Controller::getLoggedUser();
|
||||
$oldEmail = $user->email;
|
||||
|
||||
$this->verifyEmail($newEmail, $user);
|
||||
|
||||
$user->email = $newEmail;
|
||||
|
||||
$user->store();
|
||||
|
||||
$mailSender = MailSender::getInstance();
|
||||
|
@ -55,4 +59,18 @@ class EditEmail extends Controller{
|
|||
|
||||
Response::respondSuccess();
|
||||
}
|
||||
|
||||
private function verifyEmail($email, $logedUser){
|
||||
|
||||
$staff = Staff::getDataStore($email,'email');
|
||||
$user = User::getDataStore($email,'email');
|
||||
|
||||
if($user->email == $email && $logedUser->email != $email){
|
||||
throw new RequestException(ERRORS::INVALID_EMAIL);
|
||||
}
|
||||
|
||||
if($staff->email == $email){
|
||||
throw new RequestException(ERRORS::INVALID_EMAIL);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue