fix(auth): preserve OAuth identity across email changes

Link OAuth logins by provider user ID before matching email, refresh identity
claims on login, and skip password confirmation for SSO-linked users.
This commit is contained in:
Andras Bacsai
2026-08-18 15:27:27 +02:00
parent 41b06e73a0
commit f9f26c547c
5 changed files with 106 additions and 15 deletions
+5 -4
View File
@@ -4544,7 +4544,7 @@ function formatContainerStatus(string $status): string
* Check if password confirmation should be skipped.
* Returns true if:
* - Two-step confirmation is globally disabled
* - User has no password (OAuth users)
* - User has no usable local password confirmation (including SSO users)
*
* Used by modal-confirmation.blade.php to determine if password step should be shown.
*
@@ -4557,8 +4557,9 @@ function shouldSkipPasswordConfirmation(): bool
return true;
}
// Skip if user has no password (OAuth users)
if (! Auth::user()?->hasPassword()) {
// OAuth users may have an unusable generated password, so the linked
// identity is the source of truth for whether confirmation is possible.
if (! Auth::user()?->requiresPasswordConfirmation()) {
return true;
}
@@ -4569,7 +4570,7 @@ function shouldSkipPasswordConfirmation(): bool
* Verify password for two-step confirmation.
* Skips verification if:
* - Two-step confirmation is globally disabled
* - User has no password (OAuth users)
* - User has no usable local password confirmation (including SSO users)
*
* @param mixed $password The password to verify (may be array if skipped by frontend)
* @param Component|null $component Optional Livewire component to add errors to