1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace app\common\library\token;
- abstract class Driver
- {
- protected $handler = null;
- protected $options = [];
-
- abstract function set($token, $user_id, $expire = 0);
-
- abstract function get($token);
-
- abstract function check($token, $user_id);
-
- abstract function delete($token);
-
- abstract function clear($user_id);
-
- public function handler()
- {
- return $this->handler;
- }
-
- protected function getEncryptedToken($token)
- {
- $config = \think\Config::get('token');
- $token = $token ?? '';
- return hash_hmac($config['hashalgo'], $token, $config['key']);
- }
-
- protected function getExpiredIn($expiretime)
- {
- return $expiretime ? max(0, $expiretime - time()) : 365 * 86400;
- }
- }
|