From 3f7c32e299338aa8b55178a2ad31873af5278a70 Mon Sep 17 00:00:00 2001 From: hoon7566 Date: Fri, 18 Mar 2022 15:16:49 +0900 Subject: [PATCH] =?UTF-8?q?feat(customer-vue):=20customer=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=95=84=EC=9B=83=20=EA=B8=B0=EB=8A=A5=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - customer 로그아웃 기능추가 --- customer-vue/src/api/auth.js | 8 ++++++++ customer-vue/src/common/jwt.js | 3 +++ customer-vue/src/components/AppNavigation.vue | 17 ++++++++++++++++- customer-vue/src/router/router.js | 3 +-- customer-vue/src/views/LoginPage.vue | 1 - .../domain/jwt/service/OAuthService.java | 11 ----------- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/customer-vue/src/api/auth.js b/customer-vue/src/api/auth.js index 2c51de7..8066857 100644 --- a/customer-vue/src/api/auth.js +++ b/customer-vue/src/api/auth.js @@ -1,5 +1,6 @@ import axios from "axios"; import jwt from "@/common/jwt"; +import router from "@/router/router"; export default { async requestReissue() { @@ -22,5 +23,12 @@ export default { axios.defaults.headers.common['Authorization'] = "Bearer " + jwt.getToken(); return axios.get(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL+"/user-service/auth/check/access-token"); + }, + logout(){ + axios.post(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL+"/user-service/auth/logout",'',{headers: {"X-AUTH-TOKEN": jwt.getToken(),}}) + .finally(()=>{ + router.push('/login') + jwt.destroyAll() + }) } } \ No newline at end of file diff --git a/customer-vue/src/common/jwt.js b/customer-vue/src/common/jwt.js index 0783eb5..a453450 100644 --- a/customer-vue/src/common/jwt.js +++ b/customer-vue/src/common/jwt.js @@ -23,6 +23,9 @@ export default { localStorage.removeItem(EXPIRED_TIME_NAME); }, isExpired() { + if(this.getExpiredTime() == null || this.getToken() == null) + return true; + const expiredTime = this.getExpiredTime(); const expiredMoment = moment(expiredTime); diff --git a/customer-vue/src/components/AppNavigation.vue b/customer-vue/src/components/AppNavigation.vue index 85e7734..8a271e2 100644 --- a/customer-vue/src/components/AppNavigation.vue +++ b/customer-vue/src/components/AppNavigation.vue @@ -6,7 +6,7 @@ elevation="1" > - + mdi-arrow-left @@ -29,16 +29,31 @@ mdi-bell-outline + + mdi-logout +