Skip to content

Commit 607c51b

Browse files
committed
Fix method names for consistency in Social model
1 parent 064784e commit 607c51b

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

app/Http/Controllers/SocialProvider.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function github(Request $request): RedirectResponse
3636
return Socialite::driver('github')->redirect();
3737
}
3838

39-
public function callback(string $provider, Request $request): RedirectResponse
39+
public function callback(string $provider): RedirectResponse
4040
{
4141
try {
4242
$socialite = Socialite::driver($provider)->user();
@@ -46,26 +46,26 @@ public function callback(string $provider, Request $request): RedirectResponse
4646
throw new Exception('Please create password first before you can manage linking social accounts.');
4747
}
4848

49-
$socialAccontsById = Social::getUserBySocialAccountsId($provider, $socialite->id);
49+
$socialAccountById = Social::getUserBySocialAccountId($provider, $socialite->id);
5050

51-
if ($socialAccontsById->first()) {
52-
$socialAccontsById->delete();
51+
if ($socialAccountById->first()) {
52+
$socialAccountById->delete();
5353

5454
Session::regenerate();
5555

5656
return $this->redirectBack();
5757
}
5858

59-
$socialAccountByEmail = Social::getUserBySocialAccoutsEmail($provider, $socialite->email)->first();
59+
$socialAccountByEmail = Social::getUserBySocialAccoutEmail($provider, $socialite->email);
6060

61-
if ($socialAccountByEmail) {
62-
throw new Exception('Error while processing your request');
61+
if ($socialAccountByEmail->first()) {
62+
throw new Exception('Can\'t unlink social account with different email address');
6363
}
6464

65-
$socialAccontsByUserId = Social::getUserBySocialUserId($provider, $this->user->id)->first();
65+
$socialAccontsByUserId = Social::getUserBySocialUserId($provider, $this->user->id);
6666

67-
if ($socialAccontsByUserId) {
68-
throw new Exception('Error while processing your request');
67+
if ($socialAccontsByUserId->first()) {
68+
throw new Exception('Can\'t unlink social account with different email address');
6969
}
7070

7171
$socialData = [

app/Models/Social.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Social extends Model
1414
use HasUuids;
1515

1616
#[Scope]
17-
protected function getUserBySocialAccountsId(Builder $query, string $provider, string $id): void
17+
protected function getUserBySocialAccountId(Builder $query, string $provider, string $id): void
1818
{
1919
$query->where([
2020
'provider' => $provider,
@@ -23,7 +23,7 @@ protected function getUserBySocialAccountsId(Builder $query, string $provider, s
2323
}
2424

2525
#[Scope]
26-
protected function getUserBySocialAccoutsEmail(Builder $query, string $provider, string $email): void
26+
protected function getUserBySocialAccoutEmail(Builder $query, string $provider, string $email): void
2727
{
2828
$query->where([
2929
'provider' => $provider,

0 commit comments

Comments
 (0)