Example #1
0
 /**
  * Create token.
  *
  * @param T_User $user
  * @param int $expiry
  */
 protected function createToken(T_User $user, $expiry)
 {
     $token = md5(uniqid(rand()));
     $db = $this->db->master();
     $sql = 'INSERT INTO person_auth_token (token,person,expiry) ' . 'VALUES (?,?,?)';
     $data = array($token, $user->getId(), $expiry);
     $db->query($sql, $data);
     $this->cookie->set($this->key, $token, $expiry, null, null, $this->https_only);
 }
Example #2
0
 function testEmailAndIdSetInConstructor()
 {
     $user = new T_User(12, '*****@*****.**');
     $this->assertSame(12, $user->getId());
     $this->assertSame('*****@*****.**', $user->getEmail());
 }
Example #3
0
 /**
  * Deny a user all roles.
  *
  * @param T_User $user
  * @return T_Role_Gateway  fluent interface
  */
 function denyAll(T_User $user)
 {
     $sql = 'DELETE FROM person_role ' . 'WHERE person=?';
     $this->db->master()->query($sql, array($user->getId()));
     return $this;
 }
Example #4
0
 /**
  * Delete user.
  *
  * @param T_User $user
  * @return T_User_Gateway  fluent interface
  */
 function delete(T_User $user)
 {
     $sql = "DELETE FROM " . $this->getTable() . " WHERE id=" . (int) $user->getId();
     $this->db->master()->query($sql);
     $user->setId(null);
     return $this;
 }
Example #5
0
 /**
  * Whether a string is a user's password.
  *
  * @param string $pwd
  * @param T_User $user
  * @return bool  whether password is user's password
  */
 function isPwd($pwd, T_User $user)
 {
     $sql = 'SELECT COUNT(*) FROM ' . $this->getTable() . ' ' . 'WHERE id=? AND ' . $this->getPwdField() . '=?';
     $data = array($user->getId(), $this->hashPwd($pwd, $user));
     return (bool) $this->db->slave()->queryAndFetch($sql, $data);
 }