'any', 'requestData' => [ 'email' => [ 'validation' => DataValidator::oneOf( DataValidator::email()->userEmail(), DataValidator::email()->staffEmail() ), 'error' => ERRORS::INVALID_EMAIL ], 'password' => [ 'validation' => DataValidator::length(5, 200), 'error' => ERRORS::INVALID_PASSWORD ] ] ]; } public function handler() { if(!Controller::isUserSystemEnabled()) { throw new RequestException(ERRORS::USER_SYSTEM_DISABLED); } $this->requestData(); $this->changePassword(); } public function requestData() { $this->email = Controller::request('email'); $this->token = Controller::request('token'); $this->password = Controller::request('password'); } public function changePassword() { $recoverPassword = RecoverPassword::getDataStore($this->token, 'token'); if($recoverPassword->staff) { $this->user = Staff::getDataStore($this->email, 'email'); }else { $this->user = User::getDataStore($this->email, 'email'); } if (!$recoverPassword->isNull() && !$this->user->isNull()) { $recoverPassword->delete(); $this->user->setProperties([ 'password' => Hashing::hashPassword($this->password) ]); $this->user->store(); $this->sendMail(); Response::respondSuccess(['staff' => $recoverPassword->staff]); } else { throw new RequestException(ERRORS::NO_PERMISSION); } } public function sendMail() { $mailSender = MailSender::getInstance(); $mailSender->setTemplate(MailTemplate::USER_PASSWORD, [ 'to' => $this->user->email, 'url' => Setting::getSetting('url')->getValue(), 'name' => $this->user->name ]); $mailSender->send(); } }