Exemple #1
0
 public function getAuthForm()
 {
     //$form = new \Floxim\Form\Form(array('id' => 'auth_form'));
     $form = fx::data('floxim.form.form')->create();
     $form->addFields(array('email' => array('label' => 'E-mail', 'validators' => 'email -l'), 'password' => array('type' => 'password', 'label' => fx::lang('Password')), 'remember' => array('type' => 'checkbox', 'label' => fx::lang('Remember me')), 'submit' => array('type' => 'submit', 'label' => fx::lang('Log in'))));
     return $form;
 }
Exemple #2
0
 public function validate()
 {
     $fields = $this->getComponent()->getAllFields();
     foreach ($fields as $f) {
         if ($f['is_required'] && !$this[$f['keyword']]) {
             $this->invalid($f['name'] . ': ' . fx::lang('This field is required'), $f['keyword']);
         }
     }
     return parent::validate();
 }
Exemple #3
0
 public function doRecoverForm()
 {
     //$form = new \Floxim\Form\Form();
     $form = fx::data('floxim.form.form')->generate();
     $form->addFields(array('email' => array('label' => 'E-mail', 'validators' => 'email -l', 'value' => $this->getParam('email')), 'submit' => array('type' => 'submit', 'label' => fx::lang('Send me new password'))));
     if ($form->isSent() && !$form->hasErrors()) {
         $user = fx::data('floxim.user.user')->getByLogin($form->email);
         if (!$user) {
             $form->addError(fx::lang('User not found'), 'email');
         } else {
             $password = $user->generatePassword();
             $user['password'] = $password;
             $user->save();
             fx::data('session')->where('user_id', $user['id'])->delete();
             $mailer = fx::mail();
             $res = $mailer->to($form->email)->data('floxim.user.user', $user)->data('password', $password)->data('site', fx::env('site'))->template('user.password_recover')->send();
             if ($res) {
                 $form->addMessage('New password is sent to ' . $form->email);
             }
         }
     }
     return array('form' => $form);
 }