Beispiel #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);
 }
Beispiel #2
0
 function __construct($id, $email, $salt, $name, $country, $phone)
 {
     parent::__construct($id, $email);
     $this->salt = $salt;
     $this->name = $name;
     $this->ctry = $country;
     $this->phone = $phone;
 }
Beispiel #3
0
 function testEmailCanBeFilteredOnRetrieval()
 {
     $user = new T_User(12, '*****@*****.**');
     $f = new T_Test_Filter_Suffix('suffix');
     $this->assertSame($f->transform($user->getEmail()), $user->getEmail($f));
 }
Beispiel #4
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;
 }
Beispiel #5
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;
 }
Beispiel #6
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);
 }