Skip to content

Commit 0ea1012

Browse files
committed
wip
1 parent a15e5b6 commit 0ea1012

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

app/Http/Controllers/Auth/GitHubController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ public function handleProviderCallback(ConnectGitHubAccount $connectGitHubAccoun
4444
}
4545

4646
$isConnectingAttempt = session()->pull('settings.github.connect.intended', false);
47-
47+
4848
if ($isConnectingAttempt) {
4949
$currentUser = auth()->user();
50-
$githubId = $socialiteUser->getId();
5150

52-
// Check if the GitHub account is already connected to another user
53-
$existingUser = User::where('github_id', $githubId)->where('id', '!=', $currentUser->id)->first();
51+
// Check if the GitHub account is already connected to another user.
52+
$existingUser = User::where('github_id', $socialiteUser->getId())
53+
->where('id', '!=', $currentUser->id)
54+
->first();
55+
5456
if ($existingUser) {
5557
$this->error('This GitHub account is already connected to another user.');
58+
} else {
59+
$connectGitHubAccount($currentUser, $socialiteUser);
5660

57-
return redirect(route('settings.profile'));
61+
$this->success('Your GitHub account has been connected.');
5862
}
5963

60-
$connectGitHubAccount($currentUser, $socialiteUser);
61-
62-
$this->success('Your GitHub account has been connected.');
63-
6464
return redirect(route('settings.profile'));
6565
}
6666

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
@endif
4949
</div>
5050

51-
@if (!Auth::user()->hasConnectedGitHubAccount())
51+
@unless (Auth::user()->hasConnectedGitHubAccount())
5252
<x-forms.form id="github_settings_form" method="POST" action="{{ route('settings.github.connect') }}">
5353
<div class="px-4 py-3 bg-gray-50 text-right sm:px-6">
5454
<x-buttons.primary-button type="submit">
5555
Connect GitHub
5656
</x-buttons.primary-button>
5757
</div>
5858
</x-forms.form>
59-
@endif
59+
@endunless
6060
</div>
6161
</section>

0 commit comments

Comments
 (0)