예제 #1
0
 public static function genCode(User $user)
 {
     $kvdb = new KVDB('auth:codes');
     do {
         $code = sha1($user->id . ':' . self::CODE_SOLT . ':' . uniqid());
     } while ($kvdb->get($code));
     $kvdb->set($code, $user->id);
     $kvdb->expire($code, self::CODE_TTL);
     return $code;
 }
예제 #2
0
파일: User.php 프로젝트: Stoiss777/s
 public function genHash()
 {
     $kvdb = new KVDB('users:sessions');
     do {
         $code = sha1($this->id . ':' . self::HASH_SOLT . ':' . uniqid());
     } while ($kvdb->get($code));
     $kvdb->set($code, $this->id);
     $kvdb->expire($code, self::HASH_TTL);
     return $code;
 }