
--- client/views/pages/AppRouter.js
+++ client/views/pages/AppRouter.js
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 |
|
3 | 3 |
import Main from "../pages/main/Main.vue"; |
4 | 4 |
import Login from "../pages/login/Login.vue"; |
5 |
+import store from './AppStore' |
|
6 |
+import axios from 'axios'; |
|
5 | 7 |
|
6 | 8 |
// 기준정보 BaselinInformation |
7 | 9 |
import Bi001 from "./AccountingManagement/BaselineInformation/Bi001.vue"; |
... | ... | @@ -40,37 +42,39 @@ |
40 | 42 |
routes, |
41 | 43 |
}); |
42 | 44 |
|
43 |
-// AppRouter.beforeEach(async (to, from, next)=>{ |
|
44 |
-// const userId = store.state.loginUser; |
|
45 |
+AppRouter.beforeEach(async (to, from, next)=>{ |
|
46 |
+ const userId = store.state.loginUser; |
|
45 | 47 |
|
46 |
-// if(userId == null && to.path != '/login.page'){ |
|
47 |
-// var vm = this; |
|
48 |
-// axios({ |
|
49 |
-// url: '/getLoginInfo.json', |
|
50 |
-// method: 'post', |
|
51 |
-// headers: { |
|
52 |
-// 'Content-Type': 'application/json; charset=UTF-8' |
|
53 |
-// } |
|
54 |
-// }).then(function (response) { |
|
55 |
-// // 로그인 정보 있음 |
|
56 |
-// if(response.data.checkMessage.status > 0){ |
|
57 |
-// store.commit('setLoginUser',response.data.resultData.LoginUserInfo); |
|
58 |
-// next() |
|
59 |
-// }else{ |
|
60 |
-// next('/login.page') |
|
61 |
-// } |
|
62 |
-// }).catch(function (error) { |
|
63 |
-// console.log(error); |
|
64 |
-// }); |
|
65 |
-// }else{ |
|
66 |
-// if(to.path == '/login.page' && userId == null){ |
|
67 |
-// next() |
|
68 |
-// }else if(to.path != '/login.page' && userId == null){ |
|
69 |
-// next('/login.page') |
|
70 |
-// }else{ |
|
71 |
-// next() |
|
72 |
-// } |
|
73 |
-// } |
|
74 |
-// }) |
|
48 |
+ if(userId == null && to.path != '/login.page'){ |
|
49 |
+ var vm = this; |
|
50 |
+ axios({ |
|
51 |
+ url: '/getLoginInfo.json', |
|
52 |
+ method: 'post', |
|
53 |
+ headers: { |
|
54 |
+ 'Content-Type': 'application/json; charset=UTF-8' |
|
55 |
+ } |
|
56 |
+ }).then(function (response) { |
|
57 |
+ // 로그인 정보 있음 |
|
58 |
+ if(response.data.checkMessage.status > 0){ |
|
59 |
+ store.commit('setLoginUser',response.data.resultData.LoginUserInfo); |
|
60 |
+ next() |
|
61 |
+ }else{ |
|
62 |
+ next('/login.page') |
|
63 |
+ } |
|
64 |
+ }).catch(function (error) { |
|
65 |
+ console.log(error); |
|
66 |
+ }); |
|
67 |
+ }else{ |
|
68 |
+ if(to.path == '/login.page' && userId != null ){ |
|
69 |
+ next('/Cm001.page') |
|
70 |
+ }else if(to.path == '/login.page' && userId == null){ |
|
71 |
+ next() |
|
72 |
+ }else if(to.path != '/login.page' && userId == null){ |
|
73 |
+ next('/login.page') |
|
74 |
+ }else{ |
|
75 |
+ next() |
|
76 |
+ } |
|
77 |
+ } |
|
78 |
+}) |
|
75 | 79 |
|
76 | 80 |
export default AppRouter; |
--- client/views/pages/layout/Header.vue
+++ client/views/pages/layout/Header.vue
... | ... | @@ -1,10 +1,9 @@ |
1 | 1 |
<template> |
2 | 2 |
<header> |
3 |
- |
|
4 | 3 |
<div class="logo-wrap gd-12 flex justify-end align-center "> |
5 | 4 |
<ul> |
6 |
- <li>박정현님</li> |
|
7 |
- <li class="header-border">로그아웃</li> |
|
5 |
+ <li>{{ store.state.loginUser.usernm }} 님</li> |
|
6 |
+ <li class="header-border" @click="logout">로그아웃</li> |
|
8 | 7 |
</ul> |
9 | 8 |
</div> |
10 | 9 |
</header> |
... | ... | @@ -12,13 +11,33 @@ |
12 | 11 |
</template> |
13 | 12 |
|
14 | 13 |
<script> |
14 |
+import axios from 'axios'; |
|
15 |
+import store from '../AppStore'; |
|
16 |
+ |
|
15 | 17 |
export default { |
16 | 18 |
data() { |
17 | 19 |
return { |
20 |
+ store : store |
|
18 | 21 |
} |
19 | 22 |
}, |
20 | 23 |
methods: { |
21 |
- |
|
24 |
+ logout : function(){ |
|
25 |
+ const vm = this; |
|
26 |
+ axios({ |
|
27 |
+ url: '/logout.json', |
|
28 |
+ method: 'post', |
|
29 |
+ headers: { |
|
30 |
+ 'Content-Type': 'application/json; charset=UTF-8' |
|
31 |
+ }, |
|
32 |
+ }).then(function (response) { |
|
33 |
+ if(response.data.checkMessage.status > 0){ |
|
34 |
+ store.commit('setLoginUser', null); |
|
35 |
+ vm.$router.push({ path: '/login.page', query: {} }); |
|
36 |
+ } |
|
37 |
+ }).catch(function (error) { |
|
38 |
+ console.log(error); |
|
39 |
+ }); |
|
40 |
+ }, |
|
22 | 41 |
}, |
23 | 42 |
watch: { |
24 | 43 |
|
... | ... | @@ -27,6 +46,8 @@ |
27 | 46 |
|
28 | 47 |
}, |
29 | 48 |
mounted() { |
49 |
+ console.log("header mounted") |
|
50 |
+ console.log(store.state.loginUser) |
|
30 | 51 |
} |
31 | 52 |
} |
32 | 53 |
</script> |
--- client/views/pages/login/Login.vue
+++ client/views/pages/login/Login.vue
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 |
<input type="file" @change="handleFileUpload" id="fileUpload" accept="image/*" |
9 | 9 |
style="display: none;"> |
10 | 10 |
<label for="fileUpload" style="display: block; width: 100%; height: 100%; cursor: pointer;"> |
11 |
- <img v-if="imagePreview" :src="imagePreview" alt="Image preview" |
|
11 |
+ <img v-if="imagePreview" :src="'data:image/jpeg;base64,' + imagePreview" alt="Image preview" |
|
12 | 12 |
style="width: 100%; height: 100%;"> |
13 | 13 |
<div v-else style="width: 100%; height: 100%;" class="login-img"></div> |
14 | 14 |
</label> |
... | ... | @@ -17,16 +17,16 @@ |
17 | 17 |
<div class="flex-column gd-6"> |
18 | 18 |
<h1 class="mb1">LOGIN</h1> |
19 | 19 |
<div class="user-name"> |
20 |
- <p>박정현</p> |
|
20 |
+ <p>{{ member.usernm }}</p> |
|
21 | 21 |
</div> |
22 | 22 |
<div class="login-box "> |
23 | 23 |
<div class="login-user mb2"> |
24 | 24 |
<p>아이디</p> |
25 |
- <input type="text " v-model="member.userid" ref="userid" @blur="getUserInfoById"> |
|
25 |
+ <input type="text " v-model="member.userid" ref="userid" @keyup.enter="getUserInfoById()"> |
|
26 | 26 |
</div> |
27 | 27 |
<div class="login-pw mb2"> |
28 | 28 |
<p>비밀번호</p> |
29 |
- <input type="password" v-model="member.newwrd" ref="password"> |
|
29 |
+ <input type="password" v-model="member.newwrd" ref="password" @focus="getUserInfoById()"> |
|
30 | 30 |
</div> |
31 | 31 |
|
32 | 32 |
<div class="flex justify-between mb2 button-wrap"> |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 |
<label for="a">ID 저장하기</label> |
36 | 36 |
|
37 | 37 |
</div> |
38 |
- <button class="small-btn " @click="pwchange">비밀번호 변경하기</button> |
|
38 |
+ <button class="small-btn " @click="pwchange()">비밀번호 변경하기</button> |
|
39 | 39 |
</div> |
40 | 40 |
<button class="blue-btn large-btn " |
41 | 41 |
style="padding: 10px !important; font-size: 1.5rem !important;" @click="login">로그인</button> |
... | ... | @@ -44,21 +44,21 @@ |
44 | 44 |
<div class="pwchange-modal pt10" v-show="isActive"> |
45 | 45 |
<div class="flex justify-between pwchange-header"> |
46 | 46 |
<h1 class="mt1 mb4">비밀번호 변경</h1> |
47 |
- <button @click="pwChangeBtn"></button> |
|
47 |
+ <button @click="pwChangeBtn()"></button> |
|
48 | 48 |
</div> |
49 | 49 |
<div class="login-box "> |
50 | 50 |
<div class="pwchange-user mb2"> |
51 | 51 |
<p>비밀번호 변경</p> |
52 |
- <input type="text " v-model="pwChange.changedPwd"> |
|
52 |
+ <input type="password" v-model="changePw.changedPwd"> |
|
53 | 53 |
</div> |
54 | 54 |
<div class="pwchange-pw mb2"> |
55 | 55 |
<p>비밀번호 확인</p> |
56 |
- <input type="password" v-model="pwChange.CheckPwd"> |
|
56 |
+ <input type="password" v-model="changePw.CheckPwd"> |
|
57 | 57 |
</div> |
58 | 58 |
|
59 | 59 |
<button class="blue-btn large-btn " |
60 | 60 |
style="padding: 10px !important; font-size: 1.5rem !important;" |
61 |
- @click="pwChangeBtn">비밀번호 변경하기</button> |
|
61 |
+ @click="updatePassword()">비밀번호 변경하기</button> |
|
62 | 62 |
</div> |
63 | 63 |
</div> |
64 | 64 |
</div> |
... | ... | @@ -71,8 +71,9 @@ |
71 | 71 |
<script> |
72 | 72 |
|
73 | 73 |
import axios from 'axios'; |
74 |
-import { useStore } from 'vuex'; |
|
75 | 74 |
import Cookies from 'js-cookie'; |
75 |
+import { useStore } from 'vuex'; |
|
76 |
+import store from '../AppStore'; |
|
76 | 77 |
|
77 | 78 |
|
78 | 79 |
export default { |
... | ... | @@ -87,9 +88,10 @@ |
87 | 88 |
usernm: null, |
88 | 89 |
oldwrd: null, |
89 | 90 |
newwrd: null, |
91 |
+ requestURL: null, |
|
90 | 92 |
}, |
91 | 93 |
//비밀번호 변경 |
92 |
- pwChange: { |
|
94 |
+ changePw: { |
|
93 | 95 |
changedPwd: null, |
94 | 96 |
CheckPwd: null, |
95 | 97 |
}, |
... | ... | @@ -101,7 +103,6 @@ |
101 | 103 |
//회원정보 유효성 |
102 | 104 |
checkedUser : false, |
103 | 105 |
} |
104 |
- |
|
105 | 106 |
}, |
106 | 107 |
methods: { |
107 | 108 |
// login() { |
... | ... | @@ -117,18 +118,33 @@ |
117 | 118 |
reader.readAsDataURL(file); |
118 | 119 |
} |
119 | 120 |
}, |
120 |
- pwchange() { |
|
121 |
- this.isActive = true; |
|
121 |
+ //패스워드 변경 화면이동 |
|
122 |
+ async pwchange() { |
|
123 |
+ //비밀번호 미입력 |
|
124 |
+ if(!this.member.newwrd){ |
|
125 |
+ alert("비밀번호를 입력하세요.") |
|
126 |
+ return; |
|
127 |
+ } |
|
128 |
+ |
|
129 |
+ this.member.requestURL = "PASSWORDCHANGE" |
|
130 |
+ //사용자 유효 검사 |
|
131 |
+ await this.getUserInfo(); |
|
132 |
+ if(this.checkedUser){ |
|
133 |
+ this.isActive = true; |
|
134 |
+ } else { |
|
135 |
+ alert('회원정보가 일치하지 않습니다.') |
|
136 |
+ this.isActive = false; |
|
137 |
+ } |
|
122 | 138 |
}, |
123 |
- pwChangeBtn() { |
|
124 |
- this.isActive = false; |
|
125 |
- }, |
|
139 |
+ // pwChangeBtn() { |
|
140 |
+ // this.isActive = false; |
|
141 |
+ // }, |
|
126 | 142 |
|
127 | 143 |
//사용자 아이디로 이름, 이미지 조회 |
128 | 144 |
getUserInfoById: function () { |
129 | 145 |
const vm = this; |
130 | 146 |
axios({ |
131 |
- url: '/getMemberById', |
|
147 |
+ url: '/getMemberById.json', |
|
132 | 148 |
method: 'post', |
133 | 149 |
headers: { |
134 | 150 |
'Content-Type': 'application/json;' |
... | ... | @@ -137,8 +153,8 @@ |
137 | 153 |
}).then(function (response) { |
138 | 154 |
console.log(response.data) |
139 | 155 |
//1.회원 이름 |
140 |
- vm.member.usernm = response.data.getNameById; |
|
141 |
- vm.imagePreview = response.data.getImageById; |
|
156 |
+ vm.member.usernm = response.data.resultData.getNameById.resultData.member.usernm; |
|
157 |
+ vm.imagePreview = response.data.resultData.getImageById.resultData.member.base64Image; |
|
142 | 158 |
//2.회원 이미지 |
143 | 159 |
}).catch(function (error) { |
144 | 160 |
console.log(error); |
... | ... | @@ -158,6 +174,11 @@ |
158 | 174 |
//로그인 |
159 | 175 |
login: function () { |
160 | 176 |
const vm = this; |
177 |
+ |
|
178 |
+ if(!vm.member.newwrd){ |
|
179 |
+ alert("비밀번호를 입력하세요.") |
|
180 |
+ return; |
|
181 |
+ } |
|
161 | 182 |
vm.passwordExpiryCheck(); |
162 | 183 |
if (vm.passwordHaveToChange) { |
163 | 184 |
alert("Password변경이 2달이상 지났습니다.. Password를 변경해주세요.") |
... | ... | @@ -174,10 +195,9 @@ |
174 | 195 |
data: vm.member |
175 | 196 |
}).then(function (response) { |
176 | 197 |
if (response.data.checkMessage.status > 0) { |
177 |
- console.log(response.data.resultData); |
|
178 |
- store.commit('setLoginUser', response.data.resultData); |
|
198 |
+ store.commit('setLoginUser', response.data.resultData.LoginUserInfo); |
|
179 | 199 |
vm.cookieInit(); |
180 |
- vm.$router.push({ path: '/', query: {} }); |
|
200 |
+ vm.$router.push({ path: '/Cm001.page', query: {} }); |
|
181 | 201 |
console.log(store.state.loginUser); |
182 | 202 |
} |
183 | 203 |
}).catch(function (error) { |
... | ... | @@ -190,33 +210,42 @@ |
190 | 210 |
passwordExpiryCheck: function () { |
191 | 211 |
const vm = this; |
192 | 212 |
axios({ |
193 |
- url: '/checkPasswordExpiry', |
|
213 |
+ url: '/checkPasswordExpiry.json', |
|
194 | 214 |
method: 'post', |
195 | 215 |
headers: { |
196 | 216 |
'Content-Type': 'application/json;' |
197 | 217 |
}, |
198 | 218 |
data: vm.member |
199 | 219 |
}).then(function (response) { |
200 |
- vm.passwordHaveToChange = response.data.resultData; |
|
220 |
+ if(response.data.checkMessage.status !== 200) { |
|
221 |
+ alert(response.data.checkMessage.message); |
|
222 |
+ return; |
|
223 |
+ } |
|
224 |
+ vm.passwordHaveToChange = response.data.resultData.haveToChangePassword; |
|
201 | 225 |
}).catch(function (error) { |
202 | 226 |
console.log(error); |
203 | 227 |
}); |
204 | 228 |
}, |
205 | 229 |
|
206 | 230 |
//아이디 비밀번호로 회원 조회(T/F) |
207 |
- getUserInfo : function() { |
|
231 |
+ getUserInfo: function() { |
|
208 | 232 |
const vm = this; |
209 |
- axios({ |
|
210 |
- url: '/getUserInfo', |
|
211 |
- method: 'post', |
|
212 |
- headers: { |
|
213 |
- 'Content-Type': 'application/json;' |
|
214 |
- }, |
|
215 |
- data: vm.member |
|
216 |
- }).then(function (response) { |
|
217 |
- vm.checkedUser = response.data.resultData; |
|
218 |
- }).catch(function (error) { |
|
219 |
- console.log(error); |
|
233 |
+ |
|
234 |
+ return new Promise((resolve, reject) => { |
|
235 |
+ axios({ |
|
236 |
+ url: '/getUserInfo.json', |
|
237 |
+ method: 'post', |
|
238 |
+ headers: { |
|
239 |
+ 'Content-Type': 'application/json;' |
|
240 |
+ }, |
|
241 |
+ data: vm.member |
|
242 |
+ }).then(function(response) { |
|
243 |
+ vm.checkedUser = response.data.resultData.result; |
|
244 |
+ resolve(response); |
|
245 |
+ }).catch(function(error) { |
|
246 |
+ console.log(error); |
|
247 |
+ reject(error); |
|
248 |
+ }); |
|
220 | 249 |
}); |
221 | 250 |
}, |
222 | 251 |
|
... | ... | @@ -224,30 +253,30 @@ |
224 | 253 |
updatePassword: function() { |
225 | 254 |
const vm = this; |
226 | 255 |
//비밀번호 유효성 검사 |
227 |
- if(!vm.passwordValidCheck){ |
|
228 |
- return; |
|
229 |
- } |
|
230 |
- //유효한 회원인지 확인 + 로그 |
|
231 |
- vm.getUserInfo(); |
|
232 |
- if(!vm.checkedUser){ |
|
233 |
- alert("비밀번호 틀려요") |
|
234 |
- vm.$refs.password.focus(); |
|
256 |
+ if(!vm.passwordValidCheck()){ |
|
235 | 257 |
return; |
236 | 258 |
} |
237 | 259 |
|
238 | 260 |
axios({ |
239 |
- url: '/updatePassword', |
|
261 |
+ url: '/updatePassword.json', |
|
240 | 262 |
method: 'post', |
241 | 263 |
headers: { |
242 | 264 |
'Content-Type': 'application/json;' |
243 | 265 |
}, |
244 | 266 |
data: { |
245 | 267 |
userid : vm.member.userid, |
246 |
- newpwd : vm.pwChange.changedPwd, |
|
268 |
+ newwrd : vm.member.newwrd, |
|
269 |
+ changeWrd : vm.changePw.CheckPwd |
|
247 | 270 |
} |
248 | 271 |
}).then(function (response) { |
249 |
- if(response.data.resultData){ |
|
250 |
- |
|
272 |
+ if(response.data.resultData.result){ |
|
273 |
+ alert("비밀번호 변경에 성공하였습니다.") |
|
274 |
+ vm.isActive = false; |
|
275 |
+ vm.changePw.CheckPwd = null; |
|
276 |
+ vm.changePw.changedPwd = null; |
|
277 |
+ vm.member.newwrd = null; |
|
278 |
+ } else { |
|
279 |
+ alert("비밀번호 변경에 실패하였습니다.") |
|
251 | 280 |
} |
252 | 281 |
}).catch(function (error) { |
253 | 282 |
console.log(error); |
... | ... | @@ -257,12 +286,16 @@ |
257 | 286 |
|
258 | 287 |
//비밀번호 유효성 검사 |
259 | 288 |
passwordValidCheck: function() { |
260 |
- if(!this.pwChange.CheckPwd){ |
|
289 |
+ if(!this.changePw.CheckPwd){ |
|
261 | 290 |
alert("비밀번호를 입력하세요.") |
262 | 291 |
return false; |
263 | 292 |
} |
264 |
- if(this.pwChange.CheckPwd !== this.pwChange.changedPwd){ |
|
293 |
+ if(this.changePw.CheckPwd !== this.changePw.changedPwd){ |
|
265 | 294 |
alert("비밀번호가 일치하지 않습니다.") |
295 |
+ return false; |
|
296 |
+ } |
|
297 |
+ if(this.changePw.CheckPwd.length > 20){ |
|
298 |
+ alert("비밀번호는 20자리를 넘을 수 없습니다.") |
|
266 | 299 |
return false; |
267 | 300 |
} |
268 | 301 |
|
... | ... | @@ -284,6 +317,10 @@ |
284 | 317 |
} |
285 | 318 |
}, |
286 | 319 |
mounted() { |
320 |
+ if(this.member.userid){ |
|
321 |
+ console.log("쿠키확인!!!") |
|
322 |
+ this.getUserInfoById(); |
|
323 |
+ } |
|
287 | 324 |
} |
288 | 325 |
} |
289 | 326 |
</script> |
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?