'any', 'requestData' => [ 'email' => [ 'validation' => DataValidator::email()->userEmail(), 'error' => ERRORS::INVALID_EMAIL ] ] ]; } public function handler() { if(!Controller::isUserSystemEnabled()) { throw new Exception(ERRORS::USER_SYSTEM_DISABLED); } $this->staff = Controller::request('staff'); $email = Controller::request('email'); if($this->staff){ $this->user = Staff::getUser($email,'email'); }else { $this->user = User::getUser($email,'email'); } if(!$this->user->isNull()) { $this->token = Hashing::generateRandomToken(); $recoverPassword = new RecoverPassword(); $recoverPassword->setProperties(array( 'email' => $email, 'token' => $this->token, 'staff' => $this->staff )); $recoverPassword->store(); $this->sendEmail(); Response::respondSuccess(); } else { Response::respondError(ERRORS::INVALID_EMAIL); } } public function sendEmail() { $mailSender = MailSender::getInstance(); $mailSender->setTemplate(MailTemplate::PASSWORD_FORGOT, [ 'to' => $this->user->email, 'name' => $this->user->name, 'url' => Setting::getSetting('url')->getValue(), 'token' => $this->token ]); $mailSender->send(); } }