]> BookStack Code Mirror - bookstack/blobdiff - app/Access/Oidc/OidcService.php
ZIP Imports: Added API examples, finished testing
[bookstack] / app / Access / Oidc / OidcService.php
index 660885e8b2a4f30b0c2db8401efbd8a8655d6624..d6f6ef156e40020ba162b2f2bd00587d7afb74c5 100644 (file)
@@ -222,6 +222,10 @@ class OidcService
             throw new OidcException($exception->getMessage());
         }
 
+        if ($this->config()['fetch_avatar'] && !$user->avatar()->exists() && $userDetails->picture) {
+            $this->userAvatars->assignToUserFromUrl($user, $userDetails->picture);
+        }
+
         if ($this->shouldSyncGroups()) {
             $detachExisting = $this->config()['remove_from_groups'];
             $this->groupService->syncUserWithFoundGroups($user, $userDetails->groups ?? [], $detachExisting);
@@ -229,10 +233,6 @@ class OidcService
 
         $this->loginService->login($user, 'oidc');
 
-        if ($this->config()['fetch_avatars'] && $userDetails->picture) {
-            $this->userAvatars->assignToUserFromUrl($user, $userDetails->picture, $accessToken->getToken());
-        }
-
         return $user;
     }