Exemple #1
0
 /**
  * Logs in a user.
  *
  * This method is called from the login module after successful authentication.
  *
  * @param User $user the user to login
  * @param boolean $persistent whether the login is persistent
  */
 public function login(User $user, $persistent)
 {
     $id = $user->getID();
     $this->sessionLoginMethod->login($id);
     if ($persistent) {
         $this->persistentLoginMethod->login($id);
     }
 }
Exemple #2
0
 /**
  * Fetches a user by a unique property (ID, e-mail address, username).
  *
  * @param string $property the name of the property
  * @param mixed $value the value
  * @return User null user object or <code>null</code>
  */
 private function fetchByProperty($property, $value)
 {
     if (!$this->db->tableExists($this->table)) {
         return null;
     }
     $query = "SELECT * FROM :::table WHERE ::field=:value";
     $bindings = array(':::table' => $this->table, '::field' => $property, ':value' => $value);
     $result = $this->db->fetch($query, $bindings);
     if (count($result) !== 1) {
         return null;
     }
     $user = new User($result[0]['id']);
     $user->setUsername($result[0]['username']);
     $user->setFullName($result[0]['fullName']);
     $user->setEmail($result[0]['email']);
     $user->setBirthdate($result[0]['birthdate']);
     $user->setGender($result[0]['gender']);
     $user->setTimezoneOffset($result[0]['timezoneOffset']);
     $user->setLocale($result[0]['locale']);
     $user->setLastLogin($result[0]['lastLogin']);
     $user->setSecret($result[0]['secret']);
     return $user;
 }
 /**
  * Converts an array to a user object.
  *
  * @param $array the array
  * @return User the user
  */
 private function arrayToUser(array $array)
 {
     $user = new User($array['id']);
     $user->setUsername($array['username']);
     $user->setFullName($array['fullName']);
     $user->setEmail($array['email']);
     $user->setBirthdate($array['birthdate']);
     $user->setGender($array['gender']);
     $user->setTimezoneOffset($array['timezoneOffset']);
     $user->setLocale($array['locale']);
     $user->setLastLogin($array['lastLogin']);
     $user->setSecret($array['secret']);
     return $user;
 }
 /**
  * Tests removing the storage.
  *
  * @covers empire\framework\user\storage\DbUserStorage::remove
  */
 public function testRemove()
 {
     $haenschen = new User(12);
     $haenschen->setUsername('root');
     $haenschen->setFullName('Hänschen Oberschmitt');
     $haenschen->setEmail('*****@*****.**');
     $haenschen->setGender('transfemale');
     $haenschen->setBirthdate('1910-12-05');
     $haenschen->setTimezoneOffset(-4);
     $haenschen->setLocale('de-DE');
     $haenschen->setLastLogin(1394456400);
     $haenschen->setSecret('my hidden secret');
     $this->instance->store($haenschen);
     $this->instance->remove();
     $this->assertNull($this->instance->fetch(12));
 }
Exemple #5
0
 /**
  * Tests authenticate (persistent only).
  *
  * @dataProvider instancesProvider
  * @covers empire\framework\login\Login::authenticate
  *
  * @param Login $login the login to test
  */
 public function testAuthenticatePersistent($login)
 {
     $user = new User(self::GID);
     $this->remoteCall('login', $login, array($user, true));
     sleep(3);
     $expected = new User(self::GID);
     $expected->setRestricted(true);
     $res = $this->remoteCall('authenticate', $login);
     $this->assertEquals($expected, $res);
 }