This commit is contained in:
2026-03-10 22:36:46 -05:00
parent 489cfb4f71
commit 87d40ab514

View File

@@ -74,18 +74,19 @@ class EveLoginController extends Controller
private function CreateOrUpdateUser($ssoUser)
{
//Get all the data we need from the ssoUser
$characterId = strtr($ssoUser['sub'], ['CHARACTER:EVE:' => '']);
$characterName = $ssoUser['name'];
$characterOwnerHash = $ssoUser['owner'];
$avatar = 'https://image.eveonline.com/Character/' . $characterId . '_128.jpg';
$token = $ssoUser->token;
$refreshToken = $ssoUser->refreshToken ?? null;
$expiresIn = $ssoUser->expiresIn ?? null;
$scopes = is_array($ssoUser['scp']) ? $ssoUser['scp'] : [$ssoUser['scp']];
//Update user permissions, privileges, and add to database if not available.
app(\App\Services\UserPrivilegeService::class)->privilegesChanged($user, function($user) {
$user = app(\App\Services\UserPrivilegeService::class)->privilegesChanged($user, function($user) {
//Get all the data we need from the ssoUser
$characterId = strtr($ssoUser['sub'], ['CHARACTER:EVE:' => '']);
$characterName = $ssoUser['name'];
$characterOwnerHash = $ssoUser['owner'];
$avatar = 'https://image.eveonline.com/Character/' . $characterId . '_128.jpg';
$token = $ssoUser->token;
$refreshToken = $ssoUser->refreshToken ?? null;
$expiresIn = $ssoUser->expiresIn ?? null;
$scopes = is_array($ssoUser['scp']) ? $ssoUser['scp'] : [$ssoUser['scp']];
$user = User::updateOrCreate(
['character_id' => $characterId],
[
@@ -97,28 +98,28 @@ class EveLoginController extends Controller
'expiresIn' => $expiresIn,
]
);
//Delete currently saved scopes, then add the scopes used to login with.
EsiScope::where(['character_id' => $characterId])->delete();
foreach($scopes as $scope) {
$data = new EsiScope;
$data->character_id = $characterId;
$data->scope = $scope;
$data->save();
}
//Add Esi Token to the token database
$esiToken = EsiToken::updateOrCreate(
['character_id' => $characterId],
[
'access_token' => $token,
'refresh_token' => $refreshToken,
'inserted_at' => time(),
'expires_in' => $expiresIn,
]
);
});
//Delete currently saved scopes, then add the scopes used to login with.
EsiScope::where(['character_id' => $characterId])->delete();
foreach($scopes as $scope) {
$data = new EsiScope;
$data->character_id = $characterId;
$data->scope = $scope;
$data->save();
}
//Add Esi Token to the token database
$esiToken = EsiToken::updateOrCreate(
['character_id' => $characterId],
[
'access_token' => $token,
'refresh_token' => $refreshToken,
'inserted_at' => time(),
'expires_in' => $expiresIn,
]
);
//Send the object back to the calling function
return $user;
}