From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 28 Apr 2025 02:13:30 +0000
Subject: ~20250428 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/login/login-form-shi.tsx | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

(limited to 'components/login/login-form-shi.tsx')

diff --git a/components/login/login-form-shi.tsx b/components/login/login-form-shi.tsx
index fb985592..ef39d122 100644
--- a/components/login/login-form-shi.tsx
+++ b/components/login/login-form-shi.tsx
@@ -110,8 +110,25 @@ export function LoginFormSHI({
                     title: t('loginSuccess'),
                     description: t('youAreLoggedIn'),
                 });
-      
-                router.push(`/${lng}/evcp/report`);
+
+                const callbackUrlParam = searchParams?.get('callbackUrl');
+  
+                if (callbackUrlParam) {
+                  try {
+                    // URL 객체로 파싱
+                    const callbackUrl = new URL(callbackUrlParam);
+                    
+                    // pathname + search만 사용 (호스트 제거)
+                    const relativeUrl = callbackUrl.pathname + callbackUrl.search;
+                    router.push(relativeUrl);
+                  } catch (e) {
+                    // 유효하지 않은 URL이면 그대로 사용 (이미 상대 경로일 수 있음)
+                    router.push(callbackUrlParam);
+                  }
+                } else {
+                  // callbackUrl이 없으면 기본 대시보드로 리다이렉트
+                  router.push(`/${lng}/evcp/report`);
+                }
               
             } else {
                 toast({
@@ -186,8 +203,10 @@ export function LoginFormSHI({
                     <div className="mx-auto w-full flex flex-col space-y-6 sm:w-[350px]">
 
                         {/* Here's your existing login/OTP forms: */}
-                        {!otpSent ? (
-                            <form onSubmit={handleSubmit} className="p-6 md:p-8">
+                        {/* {!otpSent ? 
+                        ( */}
+                            {/* <form onSubmit={handleSubmit} className="p-6 md:p-8"> */}
+                            <form onSubmit={handleOtpSubmit} className="p-6 md:p-8">
                                 <div className="flex flex-col gap-6">
                                     <div className="flex flex-col items-center text-center">
                                         <h1 className="text-2xl font-bold">{t('loginMessage')}</h1>
@@ -232,7 +251,10 @@ export function LoginFormSHI({
                                     </div>
                                 </div>
                             </form>
-                        ) : (
+                        {/* ) 
+                        
+                        
+                        : (
                             <form onSubmit={handleOtpSubmit} className="flex flex-col gap-4 p-6 md:p-8">
                                 <div className="flex flex-col gap-6">
                                     <div className="flex flex-col items-center text-center">
@@ -283,7 +305,7 @@ export function LoginFormSHI({
                                     </div>
                                 </div>
                             </form>
-                        )}
+                        )} */}
 
                         <div className="text-balance text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 hover:[&_a]:text-primary">
                             {t('termsMessage')} <a href="#">{t('termsOfService')}</a> {t('and')}
-- 
cgit v1.2.3

