FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Token.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class Token extends \Rsi\Fred\User\Authenticator{
6 
7  public $tokenTime = 10; //!< Time (in seconds) for which the token is valid.
8 
9  protected function check(){
10  return null;
11  }
12 
13  public function token(){
14  $this->session->time = time();
15  return $this->session->token = \Rsi\Str::random();
16  }
17 
18  public function verify($secret,$hash){
19  $this->verified(
20  $secret &&
21  ($token = $this->session->token) &&
22  ($this->session->time > time() - $this->tokenTime) &&
23  hash_equals(md5($secret . $token),$hash)
24  );
25  return $this->checked;
26  }
27 
28 }
Rsi\Fred\User\Authenticator\verified
verified($result)
Process the result of a verification.
Definition: Authenticator.php:23
Rsi\Fred\User\Authenticator\Token
Definition: Token.php:5
Rsi\Fred\User\Authenticator\Token\token
token()
Definition: Token.php:13
Rsi\Fred\User\Authenticator
Definition: GeoIp.php:3
Rsi\Fred\User\Authenticator\Token\verify
verify($secret, $hash)
Definition: Token.php:18
Rsi\Fred\User\Authenticator\Token\$tokenTime
$tokenTime
Time (in seconds) for which the token is valid.
Definition: Token.php:7
Rsi\Fred\User\Authenticator\Token\check
check()
Perform the check.
Definition: Token.php:9