| | <?php |
| |
|
| | namespace Kanboard\Model; |
| |
|
| | use Kanboard\Core\Base; |
| | use Kanboard\Core\Security\Token; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | class RememberMeSessionModel extends Base |
| | { |
| | |
| | |
| | |
| | |
| | |
| | const TABLE = 'remember_me'; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | const EXPIRATION = 5184000; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function find($token, $sequence) |
| | { |
| | return $this->db |
| | ->table(self::TABLE) |
| | ->eq('token', $token) |
| | ->eq('sequence', $sequence) |
| | ->gt('expiration', time()) |
| | ->findOne(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function getAll($user_id) |
| | { |
| | return $this->db |
| | ->table(self::TABLE) |
| | ->eq('user_id', $user_id) |
| | ->desc('date_creation') |
| | ->columns('id', 'ip', 'user_agent', 'date_creation', 'expiration') |
| | ->findAll(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function create($user_id, $ip, $user_agent) |
| | { |
| | $token = hash('sha256', $user_id.$user_agent.$ip.Token::getToken()); |
| | $sequence = Token::getToken(); |
| | $expiration = time() + self::EXPIRATION; |
| |
|
| | $this->cleanup($user_id); |
| |
|
| | $this |
| | ->db |
| | ->table(self::TABLE) |
| | ->insert(array( |
| | 'user_id' => $user_id, |
| | 'ip' => $ip, |
| | 'user_agent' => substr($user_agent, 0, 255), |
| | 'token' => $token, |
| | 'sequence' => $sequence, |
| | 'expiration' => $expiration, |
| | 'date_creation' => time(), |
| | )); |
| |
|
| | return array( |
| | 'token' => $token, |
| | 'sequence' => $sequence, |
| | 'expiration' => $expiration, |
| | ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function remove($session_id) |
| | { |
| | return $this->db |
| | ->table(self::TABLE) |
| | ->eq('id', $session_id) |
| | ->remove(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function cleanup($user_id) |
| | { |
| | return $this->db |
| | ->table(self::TABLE) |
| | ->eq('user_id', $user_id) |
| | ->lt('expiration', time()) |
| | ->remove(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | public function updateSequence($token) |
| | { |
| | $sequence = Token::getToken(); |
| |
|
| | $this |
| | ->db |
| | ->table(self::TABLE) |
| | ->eq('token', $token) |
| | ->update(array('sequence' => $sequence)); |
| |
|
| | return $sequence; |
| | } |
| | } |
| |
|