Example #1
0
 public function testChangePassword()
 {
     $user = User::authentication('msaiz', 'miguel123');
     $this->assertTrue(User::authentication('msaiz', '123123') == null);
     $this->assertTrue(User::authentication('msaiz', 'miguel123') != null);
     $this->assertTrue($user->changePassword('miguel123', '123123'));
     $this->assertTrue(User::authentication('msaiz', '123123') != null);
     $this->assertTrue(User::authentication('msaiz', 'miguel123') == null);
     //Reiniciar el password
     $user->password = '******';
     $user->save();
 }
 public function action_login()
 {
     $login = '';
     $password = '';
     if (isset($_POST['log'])) {
         $login = $_POST['login'];
         $password = $_POST['password'];
         $errors = false;
         $user_login = User::check_user($login, $password);
         if ($user_login == false) {
             $errors[] = "Данные введены неверно";
         } else {
             User::authentication($user_login);
             header("Location: /");
         }
     }
     require_once dir . '/view/login.php';
     return true;
 }
Example #3
0
 public function register()
 {
     return false;
     parent::load('model', 'system/contrib/auth.User');
     /*
      * Loggined redirect to default
      */
     if (User::is_authenticated()) {
         import('system/share/network/redirect');
         HTTPRedirect::to(ini('base/DEFAULT_ACTION'));
     }
     $smarty = parent::load('smarty');
     $register_form = parent::load('form', 'LoginForm', $_POST);
     if (!$this->is_post()) {
         $smarty->assign('register_form', $register_form->output());
         $smarty->display('auth/register');
         return;
     }
     if ($register_form->is_valid() && Request::$method == 'POST') {
         $user = UserTable::findByUsername($register_form->data['username']);
         if ($user) {
             array_push($register_form->messages, _('Username exists'));
         } else {
             $user = new User();
             $user->username = $register_form->data['username'];
             $user->password = User::generate_password($register_form->data['password']);
             $user->save();
             User::authentication($user->username, $register_form->data['password']);
             import('system/share/network/redirect');
             HTTPRedirect::to(url_reverse('auth_index'));
         }
     }
     $smarty->assign('register_form', $register_form->output());
     $smarty->display('auth/register');
 }