/home/techb158/ileadtechnology.com/app/Http/Controllers/Auth
Edit: /home/techb158/ileadtechnology.com/app/Http/Controllers/Auth/LoginController.php (2793B)
status == 1)
{
if ( Auth::User()->role == "admin" || Auth::User()->role == "instructor" )
{
// do your magic here
return redirect()->route('admin.index');
}
else
{
return redirect('/home');
}
}
else{
Auth::logout();
return redirect()->route('login')->with('delete','You are deactivated !');
}
}
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function socialLogin($social)
{
return Socialite::driver($social)->redirect();
}
public function handleProviderCallback($social)
{
$userSocial = Socialite::driver($social)->user();
$user = User::where(['email' => $userSocial->getEmail()])->first();
// set the remember me cookie if the user check the box
$remember = (Input::has('remember')) ? true : false;
// attempt to do the login
if(Auth::attempt(['email' => $request->get('email') , 'password' => $request->get('password') ,
'status' => 1], $request->remember)){
return redirect()->intended('/home');
}
else
{
$errors = new MessageBag(['email' => ['Email or password is invalid.']]);
return Redirect::back()->withErrors($errors)->withInput($request->except('password'));
}
if ($user) {
Auth::login($user);
return redirect()-> action('HomeController@index');
}
else {
return view('auth.register', ['name'=> $userSocial->getName(),
'email' => $userSocial->getEmail()]);
}
}
}