Ask User’s Password When Logging with Social Account – Laravel Socialite

  laravel, laravel-socialite

I have fully functional Socialite social login with Google and Facebook but i want to add another step that is "ask a password before logging in".

This function logs the user immediately after successfully logging in with the provider:

public function callback(Request $request, $provider, SocialAccountsService $service)
    {
        if ($request->has("error")) {
            return redirect()->route("website.index");
        }

        try {

            $user = $service->createOrGetUser(
                Socialite::driver($provider)->user(),
                $provider
            );

            auth()->login($user);

        } catch (InvalidStateException $e) {
            Log::error($e->getMessage());
            return redirect()->route("auth.register.index");
        }

        return redirect()->route("dashboard.profile.index");
    }

What should i do so when they login with the provider they must insert a password before logging to my website?

Source: Laravel

Leave a Reply