하석형 하석형 05-27
250527 하석형 관리자 로그인 페이지 인증 오류 내역 알림
@ece4b61107883ab678b6269c5d55e541ee790b09
client/views/pages/login/AdminLogin.vue
--- client/views/pages/login/AdminLogin.vue
+++ client/views/pages/login/AdminLogin.vue
@@ -1,5 +1,5 @@
 <template>
-    <div class="login-page page" :class="{ 'loading-blur': isLoading }" :style="{ 'cursor': isLoading ? 'wait' : 'default' }">
+    <div class="login-page page" :class="{ 'loading-blur': isLoading }" :style="{ 'cursor': isLoading ? 'wait' : '' }">
         <div>
             <div class="admin-background-img">
                 <p>
@@ -150,74 +150,77 @@
         // 인증코드 입력
         inputCode(event) {
             const input = event.target.value.replace(/[^0-9]/g, '');
-            this.code = input;
+            this.memberInfo.code = input;
         },
 
         // 인증코드 확인
         async fnCheck() {
-            const res = await check2ndAuthProc(this.memberInfo);
-            if (res.status == 200) {
-                const loginType = res.headers['login-type']; // 세션/토큰 로그인 구분
-                if (loginType === 'J') {
-                    // JWT 방식
-                    store.commit("setAuthorization", res.headers.authorization);
-                    store.commit("setLoginMode", "J");
-                    localStorage.setItem("loginMode", "J");
-                    const base64String = store.state.authorization.split(".")[1];
-                    const base64 = base64String.replace(/-/g, "+").replace(/_/g, "/");
-                    const jsonPayload = decodeURIComponent(
-                        atob(base64).split("").map((c) => {
-                            return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
-                        }).join("")
-                    );
-                    const mbr = JSON.parse(jsonPayload);
-                    store.commit("setMbrId", mbr.mbrId);
-                    store.commit("setMbrNm", mbr.mbrNm);
-                    store.commit("setRoles", mbr.roles);
-                } else if (loginType === 'S') {
-                    store.commit("setLoginMode", "S");
-                    localStorage.setItem("loginMode", "S");
-                    const mbr = res.data;
-                    store.commit("setAuthorization", null);
-                    store.commit("setMbrId", mbr.mbrId);
-                    store.commit("setMbrNm", mbr.mbrNm);
-                    const roles = mbr.roles.map(r => ({ authority: r.authrtCd }));
-                    store.commit("setRoles", roles);
-                } else {
-                    alert("알 수 없는 로그인 방식입니다.");
-                    return;
-                }
-                const isAdmin = store.state.roles.some(role => role.authority === "ROLE_ADMIN");
-                let url = this.restoreRedirect("redirect");
-                if (url != null && url != "") {
-                    const ctx = store.state.contextPath;
-                    if (ctx !== "") {
-                        // redirect 값에서 Context Path 추가
-                        url = this.$filters.ctxPath(url);
+            try {
+                const res = await check2ndAuthProc(this.memberInfo);
+                if (res.status == 200) {
+                    const loginType = res.headers['login-type']; // 세션/토큰 로그인 구분
+                    if (loginType === 'J') {
+                        // JWT 방식
+                        store.commit("setAuthorization", res.headers.authorization);
+                        store.commit("setLoginMode", "J");
+                        localStorage.setItem("loginMode", "J");
+                        const base64String = store.state.authorization.split(".")[1];
+                        const base64 = base64String.replace(/-/g, "+").replace(/_/g, "/");
+                        const jsonPayload = decodeURIComponent(
+                            atob(base64).split("").map((c) => {
+                                return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
+                            }).join("")
+                        );
+                        const mbr = JSON.parse(jsonPayload);
+                        store.commit("setMbrId", mbr.mbrId);
+                        store.commit("setMbrNm", mbr.mbrNm);
+                        store.commit("setRoles", mbr.roles);
+                    } else if (loginType === 'S') {
+                        store.commit("setLoginMode", "S");
+                        localStorage.setItem("loginMode", "S");
+                        const mbr = res.data;
+                        store.commit("setAuthorization", null);
+                        store.commit("setMbrId", mbr.mbrId);
+                        store.commit("setMbrNm", mbr.mbrNm);
+                        const roles = mbr.roles.map(r => ({ authority: r.authrtCd }));
+                        store.commit("setRoles", roles);
                     } else {
-                        // redirect 값에서 기존 Context Path 제거
-                        url = url.replace(/^\/[^\/]+/, ""); // 첫 번째 '/' 이후의 경로만 남김
+                        alert("알 수 없는 로그인 방식입니다.");
+                        return;
                     }
-                    const routeExists = this.$router.getRoutes().some(route => route.path === url);
+                    const isAdmin = store.state.roles.some(role => role.authority === "ROLE_ADMIN");
+                    let url = this.restoreRedirect("redirect");
+                    if (url != null && url != "") {
+                        const ctx = store.state.contextPath;
+                        if (ctx !== "") {
+                            // redirect 값에서 Context Path 추가
+                            url = this.$filters.ctxPath(url);
+                        } else {
+                            // redirect 값에서 기존 Context Path 제거
+                            url = url.replace(/^\/[^\/]+/, ""); // 첫 번째 '/' 이후의 경로만 남김
+                        }
+                        const routeExists = this.$router.getRoutes().some(route => route.path === url);
 
-                    if (url == this.$filters.ctxPath("/searchId.page") || url == this.$filters.ctxPath("/resetPswd.page")) {
-                        this.$router.push({ path: this.$filters.ctxPath("/main.page") });
-                    } else if (routeExists) {
-                        this.$router.push({ path: url });
+                        if (url == this.$filters.ctxPath("/searchId.page") || url == this.$filters.ctxPath("/resetPswd.page")) {
+                            this.$router.push({ path: this.$filters.ctxPath("/main.page") });
+                        } else if (routeExists) {
+                            this.$router.push({ path: url });
+                        } else {
+                            this.$router.push({
+                                path: isAdmin ? this.$filters.ctxPath("/adm/main.page") : this.$filters.ctxPath("/")
+                            });
+                        }
                     } else {
                         this.$router.push({
                             path: isAdmin ? this.$filters.ctxPath("/adm/main.page") : this.$filters.ctxPath("/")
                         });
                     }
-                } else {
-                    this.$router.push({
-                        path: isAdmin ? this.$filters.ctxPath("/adm/main.page") : this.$filters.ctxPath("/")
-                    });
                 }
-            } else {
+            } catch (error) {
                 const errorData = error.response.data;
                 if (errorData.message != null && errorData.message != "") {
                     alert(error.response.data.message);
+                    this.$refs.code.focus();
                 } else {
                     alert("에러가 발생했습니다.\n관리자에게 문의해주세요.");
                 }
Add a comment
List