Skip to content

Commit a984f5a

Browse files
committed
Add password check before disconnecting GitHub account
1 parent be59481 commit a984f5a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

app/Http/Controllers/Settings/GitHubAccountController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ public function connect(): RedirectResponse
2323

2424
public function disconnect(DisconnectGitHubAccount $disconnectGitHubAccount): RedirectResponse
2525
{
26-
$disconnectGitHubAccount(auth()->user());
26+
$user = auth()->user();
27+
28+
if (!$user->password) {
29+
$this->error('You must set a password before disconnecting your GitHub account, otherwise, you will not be able to log in again.');
30+
31+
return redirect(route('settings.profile'));
32+
}
33+
34+
$disconnectGitHubAccount($user);
2735

2836
$this->success('Your GitHub account has been disconnected.');
2937

resources/views/users/settings/github.blade.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@
2626
</a>
2727
</div>
2828

29-
<x-forms.form method="POST" action="{{ route('settings.github.disconnect') }}">
30-
<x-buttons.danger-button type="submit">
31-
Disconnect GitHub
32-
</x-buttons.danger-button>
33-
</x-forms.form>
29+
@if (Auth::user()->password)
30+
<x-forms.form method="POST" action="{{ route('settings.github.disconnect') }}">
31+
<x-buttons.danger-button type="submit">
32+
Disconnect GitHub
33+
</x-buttons.danger-button>
34+
</x-forms.form>
35+
@else
36+
<p class="text-sm text-red-600 mt-2">
37+
You must set a password before disconnecting your GitHub account, otherwise, you will not be able to log in again.
38+
</p>
39+
@endif
3440
</div>
3541
@else
3642
<div class="flex items-center justify-between flex-wrap gap-4">

0 commit comments

Comments
 (0)