
--- client/views/pages/login/AdminLogin.vue
+++ client/views/pages/login/AdminLogin.vue
... | ... | @@ -1,5 +1,5 @@ |
1 | 1 |
<template> |
2 |
- <div class="login-page page" :class="{ 'loading-blur': isLoading }" :style="{ 'cursor': isLoading ? 'wait' : 'default' }"> |
|
2 |
+ <div class="login-page page" :class="{ 'loading-blur': isLoading }" :style="{ 'cursor': isLoading ? 'wait' : '' }"> |
|
3 | 3 |
<div> |
4 | 4 |
<div class="admin-background-img"> |
5 | 5 |
<p> |
... | ... | @@ -150,74 +150,77 @@ |
150 | 150 |
// 인증코드 입력 |
151 | 151 |
inputCode(event) { |
152 | 152 |
const input = event.target.value.replace(/[^0-9]/g, ''); |
153 |
- this.code = input; |
|
153 |
+ this.memberInfo.code = input; |
|
154 | 154 |
}, |
155 | 155 |
|
156 | 156 |
// 인증코드 확인 |
157 | 157 |
async fnCheck() { |
158 |
- const res = await check2ndAuthProc(this.memberInfo); |
|
159 |
- if (res.status == 200) { |
|
160 |
- const loginType = res.headers['login-type']; // 세션/토큰 로그인 구분 |
|
161 |
- if (loginType === 'J') { |
|
162 |
- // JWT 방식 |
|
163 |
- store.commit("setAuthorization", res.headers.authorization); |
|
164 |
- store.commit("setLoginMode", "J"); |
|
165 |
- localStorage.setItem("loginMode", "J"); |
|
166 |
- const base64String = store.state.authorization.split(".")[1]; |
|
167 |
- const base64 = base64String.replace(/-/g, "+").replace(/_/g, "/"); |
|
168 |
- const jsonPayload = decodeURIComponent( |
|
169 |
- atob(base64).split("").map((c) => { |
|
170 |
- return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2); |
|
171 |
- }).join("") |
|
172 |
- ); |
|
173 |
- const mbr = JSON.parse(jsonPayload); |
|
174 |
- store.commit("setMbrId", mbr.mbrId); |
|
175 |
- store.commit("setMbrNm", mbr.mbrNm); |
|
176 |
- store.commit("setRoles", mbr.roles); |
|
177 |
- } else if (loginType === 'S') { |
|
178 |
- store.commit("setLoginMode", "S"); |
|
179 |
- localStorage.setItem("loginMode", "S"); |
|
180 |
- const mbr = res.data; |
|
181 |
- store.commit("setAuthorization", null); |
|
182 |
- store.commit("setMbrId", mbr.mbrId); |
|
183 |
- store.commit("setMbrNm", mbr.mbrNm); |
|
184 |
- const roles = mbr.roles.map(r => ({ authority: r.authrtCd })); |
|
185 |
- store.commit("setRoles", roles); |
|
186 |
- } else { |
|
187 |
- alert("알 수 없는 로그인 방식입니다."); |
|
188 |
- return; |
|
189 |
- } |
|
190 |
- const isAdmin = store.state.roles.some(role => role.authority === "ROLE_ADMIN"); |
|
191 |
- let url = this.restoreRedirect("redirect"); |
|
192 |
- if (url != null && url != "") { |
|
193 |
- const ctx = store.state.contextPath; |
|
194 |
- if (ctx !== "") { |
|
195 |
- // redirect 값에서 Context Path 추가 |
|
196 |
- url = this.$filters.ctxPath(url); |
|
158 |
+ try { |
|
159 |
+ const res = await check2ndAuthProc(this.memberInfo); |
|
160 |
+ if (res.status == 200) { |
|
161 |
+ const loginType = res.headers['login-type']; // 세션/토큰 로그인 구분 |
|
162 |
+ if (loginType === 'J') { |
|
163 |
+ // JWT 방식 |
|
164 |
+ store.commit("setAuthorization", res.headers.authorization); |
|
165 |
+ store.commit("setLoginMode", "J"); |
|
166 |
+ localStorage.setItem("loginMode", "J"); |
|
167 |
+ const base64String = store.state.authorization.split(".")[1]; |
|
168 |
+ const base64 = base64String.replace(/-/g, "+").replace(/_/g, "/"); |
|
169 |
+ const jsonPayload = decodeURIComponent( |
|
170 |
+ atob(base64).split("").map((c) => { |
|
171 |
+ return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2); |
|
172 |
+ }).join("") |
|
173 |
+ ); |
|
174 |
+ const mbr = JSON.parse(jsonPayload); |
|
175 |
+ store.commit("setMbrId", mbr.mbrId); |
|
176 |
+ store.commit("setMbrNm", mbr.mbrNm); |
|
177 |
+ store.commit("setRoles", mbr.roles); |
|
178 |
+ } else if (loginType === 'S') { |
|
179 |
+ store.commit("setLoginMode", "S"); |
|
180 |
+ localStorage.setItem("loginMode", "S"); |
|
181 |
+ const mbr = res.data; |
|
182 |
+ store.commit("setAuthorization", null); |
|
183 |
+ store.commit("setMbrId", mbr.mbrId); |
|
184 |
+ store.commit("setMbrNm", mbr.mbrNm); |
|
185 |
+ const roles = mbr.roles.map(r => ({ authority: r.authrtCd })); |
|
186 |
+ store.commit("setRoles", roles); |
|
197 | 187 |
} else { |
198 |
- // redirect 값에서 기존 Context Path 제거 |
|
199 |
- url = url.replace(/^\/[^\/]+/, ""); // 첫 번째 '/' 이후의 경로만 남김 |
|
188 |
+ alert("알 수 없는 로그인 방식입니다."); |
|
189 |
+ return; |
|
200 | 190 |
} |
201 |
- const routeExists = this.$router.getRoutes().some(route => route.path === url); |
|
191 |
+ const isAdmin = store.state.roles.some(role => role.authority === "ROLE_ADMIN"); |
|
192 |
+ let url = this.restoreRedirect("redirect"); |
|
193 |
+ if (url != null && url != "") { |
|
194 |
+ const ctx = store.state.contextPath; |
|
195 |
+ if (ctx !== "") { |
|
196 |
+ // redirect 값에서 Context Path 추가 |
|
197 |
+ url = this.$filters.ctxPath(url); |
|
198 |
+ } else { |
|
199 |
+ // redirect 값에서 기존 Context Path 제거 |
|
200 |
+ url = url.replace(/^\/[^\/]+/, ""); // 첫 번째 '/' 이후의 경로만 남김 |
|
201 |
+ } |
|
202 |
+ const routeExists = this.$router.getRoutes().some(route => route.path === url); |
|
202 | 203 |
|
203 |
- if (url == this.$filters.ctxPath("/searchId.page") || url == this.$filters.ctxPath("/resetPswd.page")) { |
|
204 |
- this.$router.push({ path: this.$filters.ctxPath("/main.page") }); |
|
205 |
- } else if (routeExists) { |
|
206 |
- this.$router.push({ path: url }); |
|
204 |
+ if (url == this.$filters.ctxPath("/searchId.page") || url == this.$filters.ctxPath("/resetPswd.page")) { |
|
205 |
+ this.$router.push({ path: this.$filters.ctxPath("/main.page") }); |
|
206 |
+ } else if (routeExists) { |
|
207 |
+ this.$router.push({ path: url }); |
|
208 |
+ } else { |
|
209 |
+ this.$router.push({ |
|
210 |
+ path: isAdmin ? this.$filters.ctxPath("/adm/main.page") : this.$filters.ctxPath("/") |
|
211 |
+ }); |
|
212 |
+ } |
|
207 | 213 |
} else { |
208 | 214 |
this.$router.push({ |
209 | 215 |
path: isAdmin ? this.$filters.ctxPath("/adm/main.page") : this.$filters.ctxPath("/") |
210 | 216 |
}); |
211 | 217 |
} |
212 |
- } else { |
|
213 |
- this.$router.push({ |
|
214 |
- path: isAdmin ? this.$filters.ctxPath("/adm/main.page") : this.$filters.ctxPath("/") |
|
215 |
- }); |
|
216 | 218 |
} |
217 |
- } else { |
|
219 |
+ } catch (error) { |
|
218 | 220 |
const errorData = error.response.data; |
219 | 221 |
if (errorData.message != null && errorData.message != "") { |
220 | 222 |
alert(error.response.data.message); |
223 |
+ this.$refs.code.focus(); |
|
221 | 224 |
} else { |
222 | 225 |
alert("에러가 발생했습니다.\n관리자에게 문의해주세요."); |
223 | 226 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?