I am storing the user details of social authentication to User
(authenticable) model, and login the user. So that i can use the features of Auth
.
Callback function:
public function callback()
{
$user = Socialite::driver('facebook')->user();
$newUser=new User();
$newUser->name=$user->name;
$newUser->email=$user->email;
$newUser->remember_token=$user->token;
$newUser->save();
Auth::login($newUser, true);
return redirect('/');
}
But, I then realize anybody could login with just username with built in login, normal login form, if no password validations are required since we donot store facebook password in our app database. and password will be NULL in this case.
I think of deleting the user details after user logs out.
public function logout()
{
User::find(Auth::user()->id)->delete();
Auth::logout();
return redirect('/')->with('message','logged out!');
}
This doesnot looks so good. What is the correct or better way to make the socially authenticated user use Auth
?