示例#1
0
 /**
  * check token based on service
  *
  * @param string $code Hash code
  * @return array|bool
  * 
  * @url PUT totp/verify/{code}
  * @aceess public
  */
 function totpVerify($code)
 {
     $checkResult = FALSE;
     // verify code
     $totp = new TOTP();
     $service = 'google';
     switch ($service) {
         case 'google':
             $checkResult = $totp->verifyCode(TOTP_SECRET, $code);
             break;
         case 'authy':
             break;
     }
     if ($checkResult) {
         return $this->get_session();
     }
     return $checkResult;
 }
示例#2
0
 /**
  * Check if the code is correct. This will accept codes starting
  * from $discrepancy*30sec ago to $discrepancy*30sec from now
  *
  * @param string $secret
  * @param string $code
  * @return bool
  *
  * @url PUT totp/check/{secret}/{code}
  * @access protected
  */
 function totpCheck($secret = '', $code = '')
 {
     $request_data = $this->filter->run(array("secret" => $secret, "code" => $code));
     if ($this->filter->hasErrors()) {
         return $this->filter->getErrorsReturn();
     }
     $totp = new TOTP();
     $checkResult = $totp->verifyCode($secret, $code, 2);
     return $checkResult;
 }
示例#3
0
 /**
  * Get TOTP Code 
  *
  * @param string $secret
  * @return string
  *
  * @url GET totpcode/{secret}
  */
 function totpCode($secret)
 {
     $totp = new TOTP();
     $code = $totp->getCode($secret);
     return $code;
 }