sub)->first(); if (! $user) { // Fallback: search by email to map existing accounts $user = User::where('email', $data->email)->first(); if ($user) { // Link account $user->oidc_sub = $data->sub; $user->save(); } else { // Deny registration throw new AuthenticationException('Account not found. Please contact an administrator.'); } } return $user; } }