Skip to content

Commit 7e3729c

Browse files
Fixed a few issues
Problem: When the user is already added to persistence, and user signs in for the first time the dummy values in persistence were not getting updated. Solution: Updating all the user details when the user signs in for the first time. When we fill the strategy vs id on the user object for the first time. Problem: OauthToken constructor would throw Error when values are null, but null are usually expected for OauthToken Solution: Updated the constructor to accept nulls too.
1 parent bca8bd0 commit 7e3729c

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
},
1717
"require": {
18-
"encryptorcode/php-http-client": "^1.0",
19-
"encryptorcode/php-server-utils": "^1.0"
18+
"encryptorcode/php-http-client": "v1.0.0",
19+
"encryptorcode/php-server-utils": "v1.0.1"
2020
}
2121
}

composer.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/oauth/OauthToken.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class OauthToken implements \JsonSerializable{
66
private $refreshToken;
77
private $expiryTime;
88

9-
public function __construct(string $accessToken, string $refreshToken, int $expiryTime) {
9+
public function __construct(?string $accessToken, ?string $refreshToken, ?int $expiryTime) {
1010
$this->accessToken = $accessToken;
1111
$this->refreshToken = $refreshToken;
1212
$this->expiryTime = $expiryTime;

src/service/AuthenticationService.php

+4-15
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,13 @@ public function oauthCallback() : void{
8282
throw new OauthException("User was not allowed to login.");
8383
}
8484

85-
$fullName = $authUser->getFullName();
86-
if(!isset($fullName)){
87-
$authUser->setFullName($oauthUser->getFullName());
88-
}
89-
90-
$name = $authUser->getName();
91-
if(!isset($name)){
92-
$authUser->setName($oauthUser->getName());
93-
}
94-
95-
$profile = $authUser->getProfileImage();
96-
if(!isset($profile)){
97-
$authUser->setProfileImage($oauthUser->getProfileImage());
98-
}
99-
10085
$strategyVsIdMap = $authUser->getStrategyVsIdMap();
10186
if(!isset($strategyVsIdMap)){
10287
$strategyVsIdMap = array();
88+
89+
$authUser->setFullName($oauthUser->getFullName());
90+
$authUser->setName($oauthUser->getName());
91+
$authUser->setProfileImage($oauthUser->getProfileImage());
10392
}
10493

10594
$strategyVsIdMap[$strategyName] = $oauthUser->getOauthId();

0 commit comments

Comments
 (0)