feat(customer-vue): customer 로그아웃 기능추가
- customer 로그아웃 기능추가
This commit is contained in:
@@ -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()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -120,7 +120,6 @@ export default {
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
|
||||
if (!jwt.isExpired())
|
||||
await router.push("/");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user