Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AbstractAuthtokens.php
Go to the documentation of this file.
1<?php
3
12abstract class AbstractAuthtokens {
13
20 protected $id;
21
27 protected $selector;
28
35
41 protected $userid;
42
49 protected $expires;
50
51 public function __construct() {
52 $this->selector = uniqid('', true);
53 $this->hashedValidator = \bin2hex(\random_bytes(20));
54 $this->setDuration('+1 day');
55 }
56
57 public function getId() {
58 return $this->id;
59 }
60
61 public function setId($id) {
62 $this->id = $id;
63 }
64
65 public function getSelector() {
66 return $this->selector;
67 }
68
69 public function setSelector($selector) {
70 $this->selector = $selector;
71 }
72
73 public function getHashedValidator() {
75 }
76
78 $this->hashedValidator = $hashedValidator;
79 }
80
81 public function getUserid() {
82 return $this->userid;
83 }
84
85 public function setUserid($userid) {
86 $this->userid = $userid;
87 }
88
89 public function getExpires() {
90 return $this->expires;
91 }
92
93 public function setExpires($expires) {
94 $this->expires = $expires;
95 }
96
97 public function setDuration($duration) {
98 $d = new \DateTime();
99 $this->expires = $d->modify($duration);
100 }
101
102 public function isExpired() {
103 return $this->expires->getTimestamp() < (new \DateTime())->getTimestamp();
104 }
105
106 public function checkValidator($validator) {
107 return \hash_equals($this->hashedValidator, $validator);
108 }
109
114 abstract public function getUser();
115
120 abstract public function setUser($user);
121
122 public function __toString() {
123 return $this->selector . ':' . $this->hashedValidator;
124 }
125}
Ubiquity\security\auth\models$AbstractAuthtokens This class is part of Ubiquity.
$selector
@column("name"=>"selector","nullable"=>false,"dbType"=>"char(24)") @validator("length",...
$hashedValidator
@column("name"=>"hashedValidator","nullable"=>false,"dbType"=>"char(64)") @validator("length",...
$expires
@column("name"=>"expires","nullable"=>true,"dbType"=>"datetime") @validator("type",...
$userid
@column("name"=>"userid","nullable"=>false,"dbType"=>"int(11)") @validator("notNull")
$id
@id @column("name"=>"id","nullable"=>false,"dbType"=>"int(11)") @validator("id","constraints"=>array(...