Skip to content

Commit da66b42

Browse files
committed
Move login to separate function
1 parent b29ecd1 commit da66b42

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Atomx/MemoryAccountStore.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ public function __construct($username = null, $password = null, $apiBase = null)
2727
public function getToken()
2828
{
2929
if (is_null($this->token)) {
30-
$response = $this->getLoginClient()->login([
31-
'email' => $this->getUsername(),
32-
'password' => $this->getPassword(),
33-
]);
34-
35-
$this->token = $response['auth_token'];
30+
$this->storeToken($this->getTokenFromLogin());
3631
}
3732

3833
return $this->token;
@@ -43,6 +38,16 @@ protected function getLoginClient()
4338
return new Login($this);
4439
}
4540

41+
protected function getTokenFromLogin()
42+
{
43+
$response = $this->getLoginClient()->login([
44+
'email' => $this->getUsername(),
45+
'password' => $this->getPassword(),
46+
]);
47+
48+
return $response['auth_token'];
49+
}
50+
4651
/**
4752
* @param string|null $token
4853
*/

0 commit comments

Comments
 (0)