From 2d671b189af2205cd14e4eb3baad562caa7f7323 Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Sun, 31 Aug 2025 22:45:16 +0700 Subject: [PATCH] :necktie: add provider option Create a provider option in the callback handler to define the provider name for flexibility when used with multiple providers and requiring multiple endpoints. --- features/oauth-callback/lib/sendCallbackToServer.ts | 4 ++-- features/oauth-callback/ui/LoadingProcess.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/features/oauth-callback/lib/sendCallbackToServer.ts b/features/oauth-callback/lib/sendCallbackToServer.ts index ee6ab4d..4a9f206 100644 --- a/features/oauth-callback/lib/sendCallbackToServer.ts +++ b/features/oauth-callback/lib/sendCallbackToServer.ts @@ -1,9 +1,9 @@ "use server"; import { api } from "@/shared/api/connector"; -export const SendCallbackToServer = async (data: string) => { +export const SendCallbackToServer = async (data: string, provider: string) => { try { - const response = await api.get(`auth/google/callback${data}`); + const response = await api.get(`auth/${provider}/callback${data}`); const result = await response.json(); return result; diff --git a/features/oauth-callback/ui/LoadingProcess.tsx b/features/oauth-callback/ui/LoadingProcess.tsx index d873dcf..3ef51ad 100644 --- a/features/oauth-callback/ui/LoadingProcess.tsx +++ b/features/oauth-callback/ui/LoadingProcess.tsx @@ -3,8 +3,10 @@ import { CircularProgress } from "@heroui/react"; import React, { useEffect, useRef } from "react"; import { SendCallbackToServer } from "../lib/sendCallbackToServer"; +import { useParams } from "next/navigation"; const LoadingProcess = () => { + const params = useParams(); const calledRef = useRef(false); useEffect(() => { if (calledRef.current) return; @@ -12,7 +14,10 @@ const LoadingProcess = () => { (async () => { try { - await SendCallbackToServer(window.location.search); + await SendCallbackToServer( + window.location.search, + params.provider as string + ); window.close(); } catch (error) { console.log(error);