Example #1
0
 /**
  * Log a user in using the given adapter from the construct
  * @throws InvalidCredentialsException
  * @throws UnrecognisedAuthenticationResultException
  * @return boolean|throws
  */
 public function login()
 {
     $result = $this->adapter->getResult();
     if ($result === self::SKINNY_AUTH_SERVICE_SUCCESS) {
         $auth = Auth::getInstance();
         $auth->login($this->adapter->getIdentity());
         $auth->setRoles($this->adapter->getRoles());
         return true;
     } elseif ($result === self::SKINNY_AUTH_SERVICE_INVALID) {
         throw new InvalidCredentialsException('Invalid credentials exception');
     }
     throw new UnrecognisedAuthenticationResultException('Expected 1 or 2');
 }
Example #2
0
 public function testServiceValidCredentials()
 {
     $this->initLoggedOutSession();
     $adapter = new TestCaseAdapter();
     $adapter->setCredentials('*****@*****.**', 'password');
     $service = new Service($adapter);
     $result = $service->login();
     $this->assertTrue($result);
     $auth = Auth::getInstance();
     $identity = $auth->getIdentity();
     $roles = $auth->getRoles();
     $this->assertCount(2, $identity);
     $this->assertCount(2, $roles);
     $this->assertContains('admin', $roles);
 }
Example #3
0
 public function testGetNoStorage()
 {
     $this->initLoggedInSession();
     $auth = Auth::getInstance();
     $auth->destroy();
     $this->assertFalse($auth->getStorage());
 }