public function testCreateAccount()
 {
     $directory = self::$directory;
     $directory->status = 'enabled';
     $directory->save();
     $account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'surname' => 'Surname', 'email' => makeUniqueName('DirectoryTest createAccount') . '@unknown123.kot', 'password' => 'superP4ss'));
     $directory->createAccount($account, array('registrationWorkflowEnabled' => false));
     $account = \Stormpath\Resource\Account::get($account->href);
     $this->assertContains('Main_Directory', $account->directory->name);
     $this->assertEquals('Account Name', $account->givenName);
     $account->delete();
 }
 private function getAccountFromAccessToken($accessToken)
 {
     \JWT::$leeway = 10;
     $jwt = \JWT::decode($accessToken, config('stormpath.client.apiKey.secret'), ['HS256']);
     $expandsArray = [];
     $expands = config('stormpath.web.me.expand');
     foreach ($expands as $key => $value) {
         if ($value == false) {
             continue;
         }
         $expandsArray[] = $key;
     }
     $toExpand = [];
     if (count($expandsArray) > 0) {
         $toExpand = ['expand' => implode(',', $expandsArray)];
     }
     $account = \Stormpath\Resource\Account::get($jwt->sub, $toExpand);
     return $account;
 }
 public function testShouldBeAbleToGetAccountViaHTMLFragment()
 {
     $account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'middleName' => 'Middle Name', 'surname' => 'Surname', 'username' => md5(time() . microtime() . uniqid()) . 'username', 'email' => md5(time() . microtime() . uniqid()) . '@unknown123.kot', 'password' => 'superP4ss'));
     self::$directory->createAccount($account);
     $href = $account->href;
     $hrefParts = array_reverse(explode('/', $account->href));
     $acct = \Stormpath\Resource\Account::get($hrefParts[0]);
     $this->assertInstanceOf('\\Stormpath\\Resource\\Account', $account);
     $this->assertEquals($href, $acct->href);
     $acct2 = \Stormpath\Client::get($hrefParts[1] . '/' . $hrefParts[0], Stormpath::ACCOUNT);
     $this->assertInstanceOf('\\Stormpath\\Resource\\Account', $acct2);
     $this->assertEquals($href, $acct2->href);
     $account->delete();
 }
 public function testApiKeyManagement()
 {
     $application = self::$application;
     $account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'surname' => 'Surname', 'username' => md5(time()) . 'username', 'email' => md5(time()) . '@unknown123.kot', 'password' => 'superP4ss'));
     $application->createAccount($account);
     $account = \Stormpath\Resource\Account::get($account->href);
     $newApiKey = $account->createApiKey();
     $this->assertNotEmpty($newApiKey->id);
     $apiKey = $application->getApiKey($newApiKey->id);
     $this->assertEquals($newApiKey, $apiKey);
     $encryptedApiKey = $application->getApiKey($newApiKey->id, array('encryptSecret' => true));
     $this->assertEquals($apiKey->secret, $encryptedApiKey->secret);
     $apiKey->status = 'DISABLED';
     $apiKey->save();
     $this->assertEquals('DISABLED', $apiKey->status);
     $apiKey->delete();
     $apiKey = $application->getApiKey($newApiKey->id);
     $this->assertNull($apiKey);
     $account->delete();
 }
 /**
  * @expectedException \Stormpath\Resource\ResourceError
  */
 public function testDelete()
 {
     $account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'middleName' => 'Middle Name', 'surname' => 'Surname', 'username' => md5(time() . microtime() . uniqid()) . 'username', 'email' => md5(time() . microtime() . uniqid()) . '@unknown123.kot', 'password' => 'superP4ss'));
     self::$directory->createAccount($account);
     $href = $account->href;
     $account = \Stormpath\Resource\Account::get($href);
     // make sure the account exists before deleting
     $this->assertInstanceOf('Stormpath\\Resource\\Account', $account);
     $this->assertEquals('Account Name', $account->givenName);
     $account->delete();
     // should throw the expected exception after deleting
     \Stormpath\Resource\Account::get($href);
 }
 public function testCreateAccount()
 {
     $application = self::$application;
     $account = \Stormpath\Resource\Account::instantiate(array('givenName' => 'Account Name', 'surname' => 'Surname', 'username' => md5(time()) . 'username', 'email' => md5(time()) . '@unknown123.kot', 'password' => 'superP4ss'));
     $application->createAccount($account);
     $account = \Stormpath\Resource\Account::get($account->href);
     $this->assertEquals('Account Name', $account->givenName);
     $account->delete();
 }
 /**
  * Update the "remember me" token for the given user in storage.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable $user
  * @param  string $token
  * @return void
  */
 public function updateRememberToken(Authenticatable $user, $token)
 {
     $account = Account::get($user->getAuthIdentifier());
     $customData = $account->customData;
     $customData->rememberToken = $token;
 }