'any', 'requestData' => [ 'email' => [ 'validation' => DataValidator::oneOf( DataValidator::email()->userEmail(), DataValidator::email()->staffEmail() ), 'error' => ERRORS::INVALID_EMAIL ] ] ]; } public function handler() { $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 { throw new RequestException(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(); } }