feat(customer-vue): customer 로그아웃 기능추가

- customer 로그아웃 기능추가
This commit is contained in:
hoon7566
2022-03-18 15:16:49 +09:00
parent b02dcb1423
commit 3f7c32e299
6 changed files with 28 additions and 15 deletions

View File

@@ -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()
})
}
}

View File

@@ -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);

View File

@@ -6,7 +6,7 @@
elevation="1"
>
<v-app-bar-nav-icon>
<v-app-bar-nav-icon @click="$router.back()">
<v-icon>mdi-arrow-left</v-icon>
</v-app-bar-nav-icon>
<v-spacer></v-spacer>
@@ -29,16 +29,31 @@
<v-icon>mdi-bell-outline</v-icon>
</v-badge>
</v-btn>
<v-btn
color="white"
elevation="0"
@click="logout"
>
<v-icon>mdi-logout</v-icon>
</v-btn>
</v-app-bar>
</template>
<script>
import authApi from "@/api/auth";
export default {
name: "AppNavigation",
props: ["notificationCounts"],
methods: {
goNotification: function() {
this.$router.push('/notification');
},
logout: function () {
if(confirm("로그아웃하시겠습니까?")){
authApi.logout();
}
}
}
}

View File

@@ -32,7 +32,6 @@ const routes = [
{
path: '/',
redirect: 'home',
beforeEnter: authCheck,
component: HomeLayout,
children: [
{
@@ -93,12 +92,12 @@ const routes = [
{
path: '/store',
redirect: 'store',
beforeEnter: authCheck,
component: StoreLayout,
children: [
{
path: "/store/:storeId",
name: "store",
beforeEnter: authCheck,
component: () => import('../views/StoreView'),
props: true
},

View File

@@ -120,7 +120,6 @@ export default {
},
},
async mounted() {
if (!jwt.isExpired())
await router.push("/");