public function indexAction()
 {
     if (!$_POST) {
         $this->forceSecure();
     }
     $form = new \FA\Form($this->current_module_config->forms->register);
     if ($_POST && $form->isValid($_POST)) {
         $data = $form->getValues();
         // Always make the e-mails lower case.
         $data['email'] = mb_strtolower($data['email'], 'UTF-8');
         $data['email2'] = mb_strtolower($data['email2'], 'UTF-8');
         // Validate length, format, used status of the username.
         $status = $this->_checkUsername($data['username']);
         if (!$status['valid']) {
             $form->addError('username', $status['message']);
         }
         // Validate e-mail address against junk providers.
         $fa_settings = $this->di->get('fa')->settings;
         $blocked_providers = explode("\n", str_replace("\r", '', $fa_settings['Junk_Email_Providers']));
         foreach ($blocked_providers as $provider) {
             $provider = trim(strtolower($provider));
             if (!empty($provider) && strpos(strtolower($data['email']), $provider) !== FALSE) {
                 $form->addError('email', 'The use of disposable e-mail addresses or e-mail forwarders has been disabled. Please use your real e-mail address.');
                 break;
             }
         }
         // Check if e-mail address uses a common "spam e-mail" pattern.
         // f4nknve3@f4nknve3.dafa88.mobi
         $spam_email_regex = '/^([a-z0-9]{8})@\\1\\./';
         if (preg_match($spam_email_regex, $data['email'])) {
             $form->addError('email', 'The use of disposable e-mail addresses or e-mail forwarders has been disabled. Please use your real e-mail address.');
         }
         // Validation successful, send e-mail
         if (!$form->hasErrors()) {
             $rr = new RegistrationRequest();
             $rr->username = $data['username'];
             $rr->email = $data['email'];
             $rr->save();
             $confirmation_code = $rr->confirmation_code;
             \FA\Messenger::send(array('to' => $data['email'], 'subject' => 'Verify Your FurAffinity Account', 'template' => 'account_registration', 'vars' => array('form_data' => $data, 'confirmation_code' => $confirmation_code)));
             $this->view->email = $data['email'];
             return $this->view->pick('register/confirm');
         }
     }
     $this->view->title = 'Register New Account';
     return $this->renderForm($form);
 }
 public function indexAction()
 {
     $form = new \FA\Form($this->current_module_config->forms->recover);
     if ($_POST && $form->isValid($_POST)) {
         $data = $form->getValues();
         $data['email'] = mb_strtolower($data['email'], 'UTF-8');
         $user = User::getRepository()->findOneBy(array('username' => $data['username'], 'email' => $data['email']));
         if ($user instanceof User) {
             $user->lostpw = \FA\Legacy\Utilities::uuid();
             $user->save();
             \FA\Messenger::send(array('to' => $user->email, 'subject' => 'Password Recovery Code', 'template' => 'account_recover', 'vars' => array('id' => $user->id, 'code' => $user->lostpw)));
             $this->alert('<b>A password recovery link has been sent to your e-mail address.</b><br>Click the link in the e-mail to reset your password.', 'green');
             return $this->redirectHome();
         } else {
             $form->addError('username', 'We could not locate an account with this username and e-mail address in our system. Please try again!');
         }
     }
     $this->view->setVar('title', 'Forgot My Password');
     return $this->renderForm($form);
 }