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("/");
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
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.entity.Customer;
|
||||
import com.justpickup.userservice.domain.user.repository.CustomerRepository;
|
||||
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.JwtTokenProvider;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -30,8 +28,6 @@ import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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> {
|
||||
|
||||
private final CustomerRepository customerRepository;
|
||||
private final HttpServletResponse response;
|
||||
private final HttpServletRequest request;
|
||||
private final JwtTokenProvider jwtTokenProvider;
|
||||
private final RefreshTokenService refreshTokenService;
|
||||
private final UserServiceImpl userServiceImpl;
|
||||
@@ -71,11 +65,6 @@ public class OAuthService implements OAuth2UserService<OAuth2UserRequest, OAuth2
|
||||
|
||||
Collection<? extends GrantedAuthority> authorities = userServiceImpl.loadUserByUsername(userEmail).getAuthorities();
|
||||
|
||||
List<String> roles = authorities
|
||||
.stream()
|
||||
.map(GrantedAuthority::getAuthority)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new DefaultOAuth2User(
|
||||
authorities
|
||||
, attributeDto.getAttributes()
|
||||
|
||||
Reference in New Issue
Block a user