mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
fix: skip password confirmation for OAuth users
OAuth users don't have passwords set, so they should not be prompted for password confirmation when performing destructive actions. This fix: - Detects OAuth users via the hasPassword() method - Skips password confirmation in modal for OAuth users - Keeps text name confirmation as the final step - Centralizes logic in helper functions for maintainability - Changes button text to "Confirm" when password step is skipped Fixes #4457 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
@@ -3308,3 +3309,57 @@ function formatContainerStatus(string $status): string
|
||||
return str($status)->headline()->value();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if password confirmation should be skipped.
|
||||
* Returns true if:
|
||||
* - Two-step confirmation is globally disabled
|
||||
* - User has no password (OAuth users)
|
||||
*
|
||||
* Used by modal-confirmation.blade.php to determine if password step should be shown.
|
||||
*
|
||||
* @return bool True if password confirmation should be skipped
|
||||
*/
|
||||
function shouldSkipPasswordConfirmation(): bool
|
||||
{
|
||||
// Skip if two-step confirmation is globally disabled
|
||||
if (data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip if user has no password (OAuth users)
|
||||
if (! Auth::user()?->hasPassword()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify password for two-step confirmation.
|
||||
* Skips verification if:
|
||||
* - Two-step confirmation is globally disabled
|
||||
* - User has no password (OAuth users)
|
||||
*
|
||||
* @param mixed $password The password to verify (may be array if skipped by frontend)
|
||||
* @param \Livewire\Component|null $component Optional Livewire component to add errors to
|
||||
* @return bool True if verification passed (or skipped), false if password is incorrect
|
||||
*/
|
||||
function verifyPasswordConfirmation(mixed $password, ?Livewire\Component $component = null): bool
|
||||
{
|
||||
// Skip if password confirmation should be skipped
|
||||
if (shouldSkipPasswordConfirmation()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Verify the password
|
||||
if (! Hash::check($password, Auth::user()->password)) {
|
||||
if ($component) {
|
||||
$component->addError('password', 'The provided password is incorrect.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user