하관우 하관우 03-24
2025-03-24 하관우 토큰 재발급 확인을 위한 콘솔솔
@09cea7119cf4fbadc41988804cea5972b252d6e0
client/resources/api/index.js
--- client/resources/api/index.js
+++ client/resources/api/index.js
@@ -48,6 +48,7 @@
 
                 // 응답 상태가 200일 경우에만 처리
                 if (res.status === 200) {
+                    console.log("토큰 재발급 성공! 굿~");
                     // 새로 발급 받은 AccessToken 저장
                     store.commit('setAuthorization', res.headers.authorization);
                     originalReq.headers.Authorization = store.state.authorization; // 새로 발급 받은 AccessToken을 기존 요청에 추가
client/views/App.vue
--- client/views/App.vue
+++ client/views/App.vue
@@ -36,6 +36,7 @@
 
         if (res.status === 200) {
           // 새로 발급 받은 AccessToken 저장
+          console.log("토큰 재발급 성공! 굿~");
           this.store.commit('setAuthorization', res.headers.authorization);
           // JWT 토큰 디코딩
           const base64String = res.headers.authorization.split('.')[1];
client/views/pages/user/MyInfo.vue
--- client/views/pages/user/MyInfo.vue
+++ client/views/pages/user/MyInfo.vue
@@ -149,13 +149,18 @@
                     alert("수정 할 내용이 없습니다.");
                 } else {
                     if (confirm("비밀번호 변경을 하시겠습니까?")) {
-                        const response = await updatePassword(this.$store.state.userId, this.userPassword);
-                        if (response.status == 200) {
-                            this.resetForm();
-                            alert("비밀번호가 변경되었습니다.");
-                            window.location.reload(); // 페이지 새로 고침
-                        } else {
-                            alert("비밀번호 변경이 실패되었습니다.");
+                        try {
+                            const response = await updatePassword(this.$store.state.userId, this.userPassword);
+                            if (response.status === 200) {
+                                this.resetForm();
+                                alert("비밀번호가 변경되었습니다.");
+                                window.location.reload(); // 페이지 새로 고침
+                            }
+                        } catch (error) {
+                            if (error.response && error.response.status === 401) {
+                                alert("비밀번호 변경이 실패하였습니다.");
+                                window.location.reload(); // 페이지 새로 고침
+                            }
                         }
                     }
                 }
@@ -163,26 +168,36 @@
                 if (this.$store.state.userNm !== this.userInfo.userNm) {
                     if (this.isValidationPasswdord()) {
                         if (confirm("회원정보를 변경을 하시겠습니까?")) {
-                            const response = await updateUsers(this.$store.state.userId, this.userInfo);
-                            if (response.status == 200) {
-                                this.$store.commit("setUserNm", this.userInfo.userNm);
-                                this.resetForm();
-                                alert("회원정보가 변경되었습니다.");
-                                window.location.reload(); // 페이지 새로 고침
-                            } else {
-                                alert("회원정보가 변경이 실패되었습니다.");
+                            try {
+                                const response = await updateUsers(this.$store.state.userId, this.userInfo);
+                                if (response.status === 200) {
+                                    this.$store.commit("setUserNm", this.userInfo.userNm);
+                                    this.resetForm();
+                                    alert("회원정보가 변경되었습니다.");
+                                    window.location.reload(); // 페이지 새로 고침
+                                }
+                            } catch (error) {
+                                if (error.response && error.response.status === 401) {
+                                    alert("회원정보 변경이 실패하였습니다.");
+                                    window.location.reload(); // 페이지 새로 고침
+                                }
                             }
                         }
                     } else {
                         if (confirm("회원과 비밀번호를 변경하시겠습니까?")) {
-                            const res = await updateUsers(this.$store.state.userId, this.userInfo);
-                            const response = await updatePassword(this.$store.state.userId, this.userPassword);
-                            if (res.status == 200 && response.status == 200) {
-                                this.resetForm();
-                                alert("회원과 비밀번호를 변경되었습니다.");
-                                window.location.reload(); // 페이지 새로 고침
-                            } else {
-                                alert("회원과 비밀번호 변경이 실패되었습니다.");
+                            try {
+                                const res = await updateUsers(this.$store.state.userId, this.userInfo);
+                                const response = await updatePassword(this.$store.state.userId, this.userPassword);
+                                if (res.status === 200 && response.status === 200) {
+                                    this.resetForm();
+                                    alert("회원과 비밀번호를 변경되었습니다.");
+                                    window.location.reload(); // 페이지 새로 고침
+                                }
+                            } catch (error) {
+                                if (error.response && error.response.status === 401) {
+                                    alert("회원 및 비밀번호 변경이 실패하였습니다.");
+                                    window.location.reload(); // 페이지 새로 고침
+                                }
                             }
                         }
                     }
@@ -191,19 +206,24 @@
                         alert("수정 할 내용이 없습니다.");
                     } else {
                         if (confirm("비밀번호 변경을 하시겠습니까?")) {
-                            const response = await updatePassword(this.$store.state.userId, this.userPassword);
-                            if (response.status == 200) {
-                                this.resetForm();
-                                alert("비밀번호가 변경되었습니다.");
-                                window.location.reload(); // 페이지 새로 고침
-                            }else {
-                                alert("비밀번호 변경이 실패되었습니다.");
+                            try {
+                                const response = await updatePassword(this.$store.state.userId, this.userPassword);
+                                if (response.status === 200) {
+                                    this.resetForm();
+                                    alert("비밀번호가 변경되었습니다.");
+                                    window.location.reload(); // 페이지 새로 고침
+                                }
+                            } catch (error) {
+                                if (error.response && error.response.status === 401) {
+                                    alert("비밀번호 변경이 실패하였습니다.");
+                                    window.location.reload(); // 페이지 새로 고침
+                                }
                             }
                         }
                     }
                 }
             }
-        },
+        }
     },
     watch: {},
     computed: {
Add a comment
List