authenticate() public method

Authenticate user
public authenticate ( string $login, string $password ) : boolean
$login string Login
$password string Password
return boolean
 /**
  * Initialize test
  *
  * @return void
  */
 public function init()
 {
     parent::setUp();
     $this->user = UserModel::fromArray(array('lastname' => 'Test', 'firstname' => 'Test', 'email' => '*****@*****.**', 'login' => 'test-user-model', 'user_acl_role_id' => 1, 'active' => true));
     $this->user->setPassword('test-user-model-password');
     $this->user->save();
     $this->user->authenticate('test-user-model', 'test-user-model-password');
     $configuration = (include GC_APPLICATION_PATH . '/config/application.config.php');
     $configuration['module_listener_options']['config_glob_paths'] = array('tests/config/local.php');
     $this->setApplicationConfig($configuration);
 }
Example #2
0
 protected function createUser()
 {
     $this->user = UserModel::fromArray(array('lastname' => 'Test', 'firstname' => 'Test', 'email' => '*****@*****.**', 'login' => 'test-user-login', 'user_acl_role_id' => 1, 'active' => true));
     $this->user->setPassword('test-user-model-password');
     $this->user->save();
     $this->user->authenticate('test-user-login', 'test-user-model-password');
 }
Example #3
0
 /**
  * Test
  *
  * @return void
  */
 public function testFakeAuthenticate()
 {
     $this->assertFalse($this->object->authenticate('test', 'wrong password'));
 }
Example #4
0
 /**
  * Test
  *
  * @return void
  */
 public function testInvokeWithAUthenticationShouldReturnUserModel()
 {
     $this->user->authenticate('test', 'test');
     $this->assertInstanceOf('Gc\\User\\Model', $this->object->__invoke());
 }
Example #5
0
 /**
  * Login user
  *
  * @return \Zend\View\Model\ViewModel|array
  */
 public function loginAction()
 {
     if ($this->getServiceLocator()->get('Auth')->hasIdentity()) {
         $redirect = $this->getRouteMatch()->getParam('redirect');
         if (!empty($redirect)) {
             return $this->redirect()->toUrl(base64_decode($redirect));
         }
         return $this->redirect()->toRoute('admin');
     }
     $this->layout()->setTemplate('layouts/one-page.phtml');
     $loginForm = new UserLogin();
     $post = $this->getRequest()->getPost();
     if ($this->getRequest()->isPost() and $loginForm->setData($post->toArray()) and $loginForm->isValid()) {
         $userModel = new User\Model();
         $redirect = $loginForm->getValue('redirect');
         if ($userModel->authenticate($post->get('login'), $post->get('password'))) {
             if (!empty($redirect)) {
                 return $this->redirect()->toUrl(base64_decode($redirect));
             }
             return $this->redirect()->toRoute('admin');
         }
         $this->flashMessenger()->addErrorMessage('Can not connect');
         return $this->redirect()->toRoute('config/user/login', array('redirect' => $redirect));
     }
     $loginForm->get('redirect')->setValue($this->getRouteMatch()->getParam('redirect'));
     return array('form' => $loginForm);
 }