@@ -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 = [
0 commit comments