Exemple #1
0
 public function testAuthToken()
 {
     $value = $this->faker->uuid;
     $lifetime = mt_rand(1, 100);
     $token = new AuthToken($value, false, $lifetime);
     $this->assertSame($value, $token->getValue());
     $this->assertFalse($token->getVerifyAccount());
     $this->assertSame($lifetime, $token->getLifetime());
     $token = new AuthToken($value, false, 0);
     $token->setVerifyAccount(true)->setLifetime($lifetime);
     $this->assertTrue($token->getVerifyAccount());
     $this->assertSame($lifetime, $token->getLifetime());
     $xml = '<?xml version="1.0"?>' . "\n" . '<authToken verifyAccount="true" lifetime="' . $lifetime . '">' . $value . '</authToken>';
     $this->assertXmlStringEqualsXmlString($xml, (string) $token);
     $array = ['authToken' => ['verifyAccount' => true, 'lifetime' => $lifetime, '_content' => $value]];
     $this->assertEquals($array, $token->toArray());
 }
Exemple #2
0
 /**
  * Enable two factor auth
  *
  * @param  string    $name  The name of the account for which to enable two-factor auth
  * @param  string    $password  Password to use in conjunction with an account
  * @param  AuthToken $authToken  Auth token issued during the first 2FA enablement step.
  * @param  bool      $csrfSupported  Whether the client supports the CSRF token.
  * @return mixed
  */
 public function enableTwoFactorAuth($name, $password = null, AuthToken $authToken = null, $twoFactorCode = null, $csrfSupported = null)
 {
     $request = new \Zimbra\Account\Request\EnableTwoFactorAuth($name, $password, $authToken, $twoFactorCode, $csrfSupported);
     $result = $this->getClient()->doRequest($request);
     if (isset($result->authToken) && !empty($result->authToken)) {
         $this->getClient()->setAuthToken($result->authToken);
     } elseif ($authToken) {
         $this->getClient()->setAuthToken($authToken->getValue());
     }
     return $result;
 }