php - Laravel Socialite Login validate -
i have created laravel project login socialite recently.
i have deactivate account function admin. have codes prevent users login if status 1 (which deactivated) these codes doesn't work user use socialite function login.
my codes prevent deactivate user login shown below.
protected function authenticated($request, $user){ if(auth::attempt(['email' => $request->email, 'password' => $request->password, 'status' => 0])) { if($user->role == 2) { return redirect()->intended('/admin/users'); }else{ return redirect()->intended('/'); } }else{ auth::logout(); return back()->with('error', 'your account deactivated.'); } }
controller socialite
<?php namespace app\http\controllers; use illuminate\http\request; use app\http\requests; use app\socialaccountservice; use socialite; use app\user; class socialauthcontroller extends controller { public function facebookredirect() { return socialite::driver('facebook')->redirect(); } public function facebookcallback(socialaccountservice $service) { $fbuser = $service->facebookcreateorgetuser(socialite::driver('facebook')->user()); auth()->login($fbuser); return redirect()->to('/'); //$facebookuser = socialite::driver('facebook')->user(); //$facebookfirstnameaccess = $facebookuser->user['first_name']; //echo $facebookfirstnameaccess; //dd($facebookuser); } public function googleredirect() { return socialite::driver('google')->redirect(); } public function googlecallback(socialaccountservice $service) { $guser = $service->googlecreateorgetuser(socialite::driver('google')->user()); auth()->login($guser); //$googleuser = socialite::driver('google')->user(); return redirect()->to('/'); //$fname = $googleuser->firstname = $googleuser->user['name']['givenname']; //$lname = $googleuser->lastname = $googleuser->user['name']['familyname']; //echo $lname; //dd($googleuser); } }
is there anywhere me prevent user login socialite if have deactivated account?
Comments
Post a Comment