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 }
verified($result)
Process the result of a verification.
$tokenTime
Time (in seconds) for which the token is valid.
Definition: Token.php:7