1
0
Fork 0

app/Http/Controllers/Auth/OAuthController.php: check trashed records before trying to login via oauth.

This commit is contained in:
Henrik Hautakoski 2021-07-13 18:47:24 +02:00
parent de19260f35
commit d8917e118b

View file

@ -30,6 +30,12 @@ class OAuthController extends Controller
{
$oauth = Socialite::driver($driver)->stateless()->user();
// Check that account is not deleted before trying to find/create user and login.
if (User::onlyTrashed()->where("{$driver}_id", $oauth->getId())->first()) {
return redirect('/')
->with(['error' => "Account suspended."]);
}
$user = User::firstOrCreate([ "{$driver}_id" => $oauth->getId() ], [
'username' => $oauth->getNickname()
]);