Пример #1
0
 public function loginAction()
 {
     $auth = $this->session->get('auth');
     if ($auth) {
         $this->response->redirect('/');
     }
     $this->view->setMainView('login');
     $this->view->setLayout('login');
     if ($this->request->isPost()) {
         $usuario = $this->request->getPost('username');
         $password = $this->request->getPost('password');
         $password = hash_hmac('sha256', $password, '2, 4, 6, 7, 9, 15, 20, 23, 25, 30');
         //sigec users
         //$password = sha1($password);
         $user = usuarios::findFirst(array("username = :usuario: AND password = :password: AND habilitado= :estado:", "bind" => array('usuario' => $usuario, 'password' => $password, 'estado' => 1)));
         if ($user != false) {
             //acutalizamos la cantidad de ingresos
             $user->logins = $user->logins + 1;
             $user->lastlogin = time();
             $user->save();
             $this->_registerSession($user);
             $this->flashSession->success('Bienvenido <i>' . $user->nombre . '</i>');
             $this->response->redirect('/dashboard');
         }
         $this->flashSession->error('<b>Acceso denegado :</b> Usuario/contraseña incorrectos, o usuario No habilitado');
     }
     // return $this->forward('session/index');
 }
 protected function usuario()
 {
     $auth = $this->session->get('cite');
     if ($auth) {
         $user_id = $auth['id'];
         $this->_user = usuarios::findFirst("id = '{$user_id}'");
         return $this->_user;
     } else {
         return false;
     }
 }
Пример #3
0
 public function passwordAction()
 {
     $this->view->setMainView('login');
     $this->view->setLayout('login');
     if ($this->request->isPost()) {
         $email = $this->request->getPost('email');
         //buscamos el mail
         $user = usuarios::findFirst(array("email = :email: AND habilitado= :estado:", "bind" => array('email' => $email, 'estado' => 1)));
         if ($user != false) {
             //acutalizamos la cantidad de ingresos
             $user->logins = $user->logins + 1;
             $user->lastlogin = time();
             $user->save();
             $this->_registerSession($user);
             $this->flashSession->success('Bienvenido <i>' . $user->nombre . '</i>');
             $this->response->redirect('/dashboard');
         }
         $this->flashSession->error('Email inexsitente en el sistema, o usuario No habilitado');
     }
 }