checkTotp(Base32::decode($this->secret), $this->code); } /** * Called before to prompt the user * * @access public */ public function beforeCode() { } /** * Set validation code * * @access public * @param string $code */ public function setCode($code) { $this->code = $code; } /** * Generate secret * * @access public * @return string */ public function generateSecret() { $this->secret = GoogleAuthenticator::generateRandom(); return $this->secret; } /** * Set secret token * * @access public * @param string $secret */ public function setSecret($secret) { $this->secret = $secret; } /** * Get secret token * * @access public * @return string */ public function getSecret() { return $this->secret; } /** * Get QR code url * * @access public * @param string $label * @return string */ public function getQrCodeUrl($label) { if (empty($this->secret)) { return ''; } return GoogleAuthenticator::getQrCodeUrl('totp', $label, $this->secret); } /** * Get key url (empty if no url can be provided) * * @access public * @param string $label * @return string */ public function getKeyUrl($label) { if (empty($this->secret)) { return ''; } return GoogleAuthenticator::getKeyUri('totp', $label, $this->secret); } }