/** * 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); }
function testEmailAndIdSetInConstructor() { $user = new T_User(12, '*****@*****.**'); $this->assertSame(12, $user->getId()); $this->assertSame('*****@*****.**', $user->getEmail()); }
/** * 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; }
/** * 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; }
/** * 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); }