title: Next Auth: Redirect page before success login
body: <p>I want make a custom login use next Auth.</p>
  <p>What I want is, after check my email and password true, I want redirect to google auth page and after google auth true I want set the token to session and redirect to home. Is it possible to make it like that?</p>
  <pre class="lang-js prettyprint-override"><code>//This is the flow
  
  Login -&gt; google Auth -&gt; Home
  </code></pre>
  <p>This is login page</p>
  <pre class="lang-js prettyprint-override"><code>//Front End 
  
  const handler = async (e: React.FormEvent&lt;HTMLFormElement&gt;) =&gt; {
      e.preventDefault();
      setLoading(true);
      const res = await signIn(&quot;credentials&quot;, {
        redirect: false,
        data: emailRef.current?.value,
        password: passwordRef.current?.value,
      });
      if (res?.error) {
        toast.error(res?.error);
        setLoading(false);
      } else {
        Router.replace(&quot;/&quot;);
        Router.events.on(&quot;routeChangeComplete&quot;, success);
      }
    };
  </code></pre>
  <p>This is the API Page</p>
  <pre class="lang-js prettyprint-override"><code>//API
  
  export default NextAuth({
    session: {
      jwt: true,
    },
  
    providers: [
      Providers.Credentials({
        async authorize(credentials: credentialsData, req: NextApiRequest) {
          let client;
          try {
            client = await ConnectDatabase();
          } catch (error) {
            throw new Error(&quot;Failed connet to database.&quot;);
          }
  
          const checkEmail = await client
            .db()
            .collection(&quot;users&quot;)
            .findOne({ email: credentials.data });
          const checkPhone = await client
            .db()
            .collection(&quot;users&quot;)
            .findOne({ phone: credentials.data });
  
          let validData = {
            password: &quot;&quot;,
            email: &quot;&quot;,
          };
  
          if (!checkEmail &amp;&amp; !checkPhone) {
            client.close();
            throw new Error(&quot;Email atau No HP tidak terdaftar.&quot;);
          } else if (checkEmail) {
            validData = checkEmail;
          } else if (checkPhone) {
            validData = checkPhone;
          }
  
          const checkPassword = await VertifyPassword(
            credentials.password,
            validData.password
          );
          if (!checkPassword) {
            client.close();
            throw new Error(&quot;Password Salah.&quot;);
          }
          client.close();
  
          return validData;
        },
      }),
    ],
    callbacks: {
      async session(session) {
        const data = await getSelectedUser(session.user!.email!);
        session.user = data.userData;
        return Promise.resolve(session);
      },
    },
  });
  
  </code></pre>
  <p>In above Example I don't use google auth, so after login success it immediately redirects to home</p>