예제 #1
0
 public function onGenerate()
 {
     $gauth = new GoogleAuthenticator();
     $this->model->{$this->valueFrom} = $gauth->generateSecret();
     $this->prepareVars();
     return ['#mfaSecret' => $this->makePartial('usersecret_contents')];
 }
예제 #2
0
 /**
  * Check if code given is the same generated by secret
  * @param string $code
  * @return bool return true if the code is the same
  */
 public function check($code)
 {
     return $this->googleAuthenticator->checkCode($this->secret, $code);
 }
 /**
  * Generate a new secret for Google Authenticator.
  *
  * @return string
  */
 public function generateSecret()
 {
     return $this->authenticator->generateSecret();
 }
 public function testGetUrl()
 {
     $url = $this->helper->getUrl('foo', 'foobar.org', '3DHTQX4GCRKHGS55CJ');
     $expected = "https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/foo@foobar.org%3Fsecret%3D3DHTQX4GCRKHGS55CJ";
     $this->assertEquals($expected, $url);
 }