feat(customer-vue): customer 로그아웃 기능추가
- customer 로그아웃 기능추가
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import jwt from "@/common/jwt";
|
import jwt from "@/common/jwt";
|
||||||
|
import router from "@/router/router";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async requestReissue() {
|
async requestReissue() {
|
||||||
@@ -22,5 +23,12 @@ export default {
|
|||||||
axios.defaults.headers.common['Authorization'] = "Bearer " + jwt.getToken();
|
axios.defaults.headers.common['Authorization'] = "Bearer " + jwt.getToken();
|
||||||
|
|
||||||
return axios.get(process.env.VUE_APP_CUSTOMER_SERVICE_BASEURL+"/user-service/auth/check/access-token");
|
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);
|
localStorage.removeItem(EXPIRED_TIME_NAME);
|
||||||
},
|
},
|
||||||
isExpired() {
|
isExpired() {
|
||||||
|
if(this.getExpiredTime() == null || this.getToken() == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
const expiredTime = this.getExpiredTime();
|
const expiredTime = this.getExpiredTime();
|
||||||
|
|
||||||
const expiredMoment = moment(expiredTime);
|
const expiredMoment = moment(expiredTime);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
elevation="1"
|
elevation="1"
|
||||||
|
|
||||||
>
|
>
|
||||||
<v-app-bar-nav-icon>
|
<v-app-bar-nav-icon @click="$router.back()">
|
||||||
<v-icon>mdi-arrow-left</v-icon>
|
<v-icon>mdi-arrow-left</v-icon>
|
||||||
</v-app-bar-nav-icon>
|
</v-app-bar-nav-icon>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
@@ -29,16 +29,31 @@
|
|||||||
<v-icon>mdi-bell-outline</v-icon>
|
<v-icon>mdi-bell-outline</v-icon>
|
||||||
</v-badge>
|
</v-badge>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
color="white"
|
||||||
|
elevation="0"
|
||||||
|
@click="logout"
|
||||||
|
>
|
||||||
|
<v-icon>mdi-logout</v-icon>
|
||||||
|
</v-btn>
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import authApi from "@/api/auth";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "AppNavigation",
|
name: "AppNavigation",
|
||||||
props: ["notificationCounts"],
|
props: ["notificationCounts"],
|
||||||
methods: {
|
methods: {
|
||||||
goNotification: function() {
|
goNotification: function() {
|
||||||
this.$router.push('/notification');
|
this.$router.push('/notification');
|
||||||
|
},
|
||||||
|
logout: function () {
|
||||||
|
if(confirm("로그아웃하시겠습니까?")){
|
||||||
|
authApi.logout();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
redirect: 'home',
|
redirect: 'home',
|
||||||
beforeEnter: authCheck,
|
|
||||||
component: HomeLayout,
|
component: HomeLayout,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@@ -93,12 +92,12 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: '/store',
|
path: '/store',
|
||||||
redirect: 'store',
|
redirect: 'store',
|
||||||
beforeEnter: authCheck,
|
|
||||||
component: StoreLayout,
|
component: StoreLayout,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "/store/:storeId",
|
path: "/store/:storeId",
|
||||||
name: "store",
|
name: "store",
|
||||||
|
beforeEnter: authCheck,
|
||||||
component: () => import('../views/StoreView'),
|
component: () => import('../views/StoreView'),
|
||||||
props: true
|
props: true
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
|
||||||
if (!jwt.isExpired())
|
if (!jwt.isExpired())
|
||||||
await router.push("/");
|
await router.push("/");
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.justpickup.userservice.domain.jwt.service;
|
package com.justpickup.userservice.domain.jwt.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.justpickup.userservice.domain.user.dto.OAuthAttributeDto;
|
import com.justpickup.userservice.domain.user.dto.OAuthAttributeDto;
|
||||||
import com.justpickup.userservice.domain.user.entity.Customer;
|
import com.justpickup.userservice.domain.user.entity.Customer;
|
||||||
import com.justpickup.userservice.domain.user.repository.CustomerRepository;
|
import com.justpickup.userservice.domain.user.repository.CustomerRepository;
|
||||||
import com.justpickup.userservice.domain.user.service.UserServiceImpl;
|
import com.justpickup.userservice.domain.user.service.UserServiceImpl;
|
||||||
import com.justpickup.userservice.global.dto.Result;
|
|
||||||
import com.justpickup.userservice.global.utils.CookieProvider;
|
import com.justpickup.userservice.global.utils.CookieProvider;
|
||||||
import com.justpickup.userservice.global.utils.JwtTokenProvider;
|
import com.justpickup.userservice.global.utils.JwtTokenProvider;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -30,8 +28,6 @@ import java.io.IOException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
@@ -42,8 +38,6 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
|||||||
public class OAuthService implements OAuth2UserService<OAuth2UserRequest, OAuth2User> {
|
public class OAuthService implements OAuth2UserService<OAuth2UserRequest, OAuth2User> {
|
||||||
|
|
||||||
private final CustomerRepository customerRepository;
|
private final CustomerRepository customerRepository;
|
||||||
private final HttpServletResponse response;
|
|
||||||
private final HttpServletRequest request;
|
|
||||||
private final JwtTokenProvider jwtTokenProvider;
|
private final JwtTokenProvider jwtTokenProvider;
|
||||||
private final RefreshTokenService refreshTokenService;
|
private final RefreshTokenService refreshTokenService;
|
||||||
private final UserServiceImpl userServiceImpl;
|
private final UserServiceImpl userServiceImpl;
|
||||||
@@ -71,11 +65,6 @@ public class OAuthService implements OAuth2UserService<OAuth2UserRequest, OAuth2
|
|||||||
|
|
||||||
Collection<? extends GrantedAuthority> authorities = userServiceImpl.loadUserByUsername(userEmail).getAuthorities();
|
Collection<? extends GrantedAuthority> authorities = userServiceImpl.loadUserByUsername(userEmail).getAuthorities();
|
||||||
|
|
||||||
List<String> roles = authorities
|
|
||||||
.stream()
|
|
||||||
.map(GrantedAuthority::getAuthority)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
return new DefaultOAuth2User(
|
return new DefaultOAuth2User(
|
||||||
authorities
|
authorities
|
||||||
, attributeDto.getAttributes()
|
, attributeDto.getAttributes()
|
||||||
|
|||||||
Reference in New Issue
Block a user