diff --git a/client/src/components/MyPage/MyPage.js b/client/src/components/MyPage/MyPage.js
index 6c264ffc..4ec49af2 100644
--- a/client/src/components/MyPage/MyPage.js
+++ b/client/src/components/MyPage/MyPage.js
@@ -68,7 +68,7 @@ function MyPage() {
const [withdrawModal, setWithdrawModal] = useState(false);
- const [accompanyList, setAccompanyList] = useState(["안녕하세요","안녕하세요","안녕하세요","안녕하세요","안녕하세요"]) // 동행 신청 현황
+ const [accompanyList, setAccompanyList] = useState(["1","2","3","4","5"]) // 동행 신청 현황
var ranklist = "";
var size = posts.length;
@@ -505,13 +505,33 @@ function MyPage() {
- {item}
-
)}
diff --git a/client/src/components/Navbar/Navbar.css b/client/src/components/Navbar/Navbar.css
index 60d84422..7b14069b 100644
--- a/client/src/components/Navbar/Navbar.css
+++ b/client/src/components/Navbar/Navbar.css
@@ -294,7 +294,7 @@
}
.drawer .btn {
- width: 100%;
+ width: 80%;
text-align: left;
padding: 10px;
color: #fff;
diff --git a/client/src/components/Navbar/Navbar.js b/client/src/components/Navbar/Navbar.js
index 7bde879c..e28f2c27 100644
--- a/client/src/components/Navbar/Navbar.js
+++ b/client/src/components/Navbar/Navbar.js
@@ -40,12 +40,23 @@ function NavBar() {
})
eventSource.addEventListener('SSE',event => {
- console.log("event",event);
const newMessage = event.data;
- console.log('newMessage : ', event.data);
- setMessages(prevMessages => [...prevMessages, newMessage]);
+ if(newMessage[0] === '{')
+ {
+ const jsonData = JSON.parse(newMessage);
+
+ const senderName = jsonData.senderName;
+ const review = jsonData.review;
+ const postDate = jsonData.postDate;
+
+ const notificationString = `${senderName}님이\n ${review.slice(0,4)}..를 입력하였습니다.\n ${postDate}`
+ setMessages(prevMessages => [...prevMessages, notificationString])
+ }
+ else{
+ setMessages(prevMessages => [...prevMessages, newMessage]);
+ }
});
eventSource.onopen =() => {
@@ -53,17 +64,6 @@ function NavBar() {
console.log('eventSource',eventSource);
}
- eventSource.onmessage = (event) => {
- try{
- console.log('SSE message received: ', event.data);
- const newMessage = event.data;
- setMessages(prevMessages => [...prevMessages, newMessage]);
- }
- catch(error){
- console.log("Error in onmessage: ", error);
- }
- }
-
eventSource.onerror = (error) => {
console.log("SSE connection closed");
}
@@ -105,8 +105,9 @@ function NavBar() {
}
function logout() {
- axios
- .get("http://localhost:8080/api/members/logout",{
+ if(token !== null){
+ axios
+ .post("http://localhost:8080/api/members/logout",token,{
headers:{
'Authorization': `Bearer ${token}`
}
@@ -125,6 +126,7 @@ function NavBar() {
});
window.location.href = "/";
+ }
}
var offset = localStorage.getItem("vest");
diff --git a/client/src/components/StartPage/StartAnimationPage.js b/client/src/components/StartPage/StartAnimationPage.js
index 60ba6efc..9ee5b952 100644
--- a/client/src/components/StartPage/StartAnimationPage.js
+++ b/client/src/components/StartPage/StartAnimationPage.js
@@ -241,6 +241,8 @@ function StartAnimation() {
const [showModal, setShowModal] = useState(false);
const [firstShowModal, setFirstShowModal] = useState(false);
+
+ const [passwordModal, setPasswordModal] = useState(false);
const [name, setName] = useState("1"); //이름
@@ -290,6 +292,14 @@ function StartAnimation() {
}
};
+ const handlePasswordModalOpen = () => {
+ setPasswordModal(true)
+ }
+
+ const handlePasswordModalClose = () => {
+ setPasswordModal(false)
+ }
+
const handleNameChange = (event) => setName(event.target.value);
const handleGenderChange = (event) => setGender(event.target.value);
@@ -524,7 +534,26 @@ function StartAnimation() {
-
+
+
+ 비밀번호 찾기
+
+
+
+ Find Password
+
+
+
+
+
+
+
diff --git a/src/main/java/GraduationProject/TripPlannerZ/RedisConfig.java b/src/main/java/GraduationProject/TripPlannerZ/RedisConfig.java
index 027d22ef..30b1f982 100644
--- a/src/main/java/GraduationProject/TripPlannerZ/RedisConfig.java
+++ b/src/main/java/GraduationProject/TripPlannerZ/RedisConfig.java
@@ -33,6 +33,12 @@ public RedisConnectionFactory redisConnectionFactory() {
return redisTemplate;
}
+ @Bean
+ public RedisTemplate, ?> blackList() {
+ RedisTemplate redisTemplate = new RedisTemplate<>();
+ redisTemplate.setConnectionFactory((redisConnectionFactory()));
+ return redisTemplate;
+ }
}
diff --git a/src/main/java/GraduationProject/TripPlannerZ/config/JwtAuthFilter.java b/src/main/java/GraduationProject/TripPlannerZ/config/JwtAuthFilter.java
index dd6dbb70..028c89bb 100644
--- a/src/main/java/GraduationProject/TripPlannerZ/config/JwtAuthFilter.java
+++ b/src/main/java/GraduationProject/TripPlannerZ/config/JwtAuthFilter.java
@@ -1,5 +1,6 @@
package GraduationProject.TripPlannerZ.config;
+import GraduationProject.TripPlannerZ.util.RedisUtil;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
@@ -16,6 +17,7 @@
public class JwtAuthFilter extends OncePerRequestFilter {
private final UserAuthProvider userAuthProvider;
+ private final RedisUtil redisUtil;
@Override
protected void doFilterInternal(HttpServletRequest request,
@@ -29,6 +31,12 @@ protected void doFilterInternal(HttpServletRequest request,
String[] elements = header.split(" ");
System.out.println("elements[1] = " + elements[1]);
+ if (elements.length == 2 && "Bearer".equals(elements[0])) {
+ if (redisUtil.existBlackList(elements[1])) {
+ throw new RuntimeException("유효하지 않은 토큰 입니다.");
+ }
+ }
+
// key가 Bearer이고 value가 멤버의 토큰값
if (elements.length == 2 && "Bearer".equals(elements[0])) {
try {
diff --git a/src/main/java/GraduationProject/TripPlannerZ/config/SecurityConfig.java b/src/main/java/GraduationProject/TripPlannerZ/config/SecurityConfig.java
index 69110953..0fc39855 100644
--- a/src/main/java/GraduationProject/TripPlannerZ/config/SecurityConfig.java
+++ b/src/main/java/GraduationProject/TripPlannerZ/config/SecurityConfig.java
@@ -1,5 +1,6 @@
package GraduationProject.TripPlannerZ.config;
+import GraduationProject.TripPlannerZ.util.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -17,13 +18,14 @@ public class SecurityConfig {
private final UserAuthenticationEntryPoint userAuthenticationEntryPoint;
private final UserAuthProvider userAuthProvider;
+ private final RedisUtil redisUtil;
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.exceptionHandling().authenticationEntryPoint(userAuthenticationEntryPoint)
.and()
- .addFilterBefore(new JwtAuthFilter(userAuthProvider), BasicAuthenticationFilter.class)
+ .addFilterBefore(new JwtAuthFilter(userAuthProvider, redisUtil), BasicAuthenticationFilter.class)
.csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
diff --git a/src/main/java/GraduationProject/TripPlannerZ/controller/MemberController.java b/src/main/java/GraduationProject/TripPlannerZ/controller/MemberController.java
index ba646567..94c0743f 100644
--- a/src/main/java/GraduationProject/TripPlannerZ/controller/MemberController.java
+++ b/src/main/java/GraduationProject/TripPlannerZ/controller/MemberController.java
@@ -2,19 +2,15 @@
import GraduationProject.TripPlannerZ.config.UserAuthProvider;
import GraduationProject.TripPlannerZ.domain.MemberPreference;
-import GraduationProject.TripPlannerZ.dto.member.Credential;
-import GraduationProject.TripPlannerZ.dto.member.MemberDto;
-import GraduationProject.TripPlannerZ.dto.member.MemberRegister;
+import GraduationProject.TripPlannerZ.dto.member.*;
import GraduationProject.TripPlannerZ.domain.Member;
-import GraduationProject.TripPlannerZ.dto.member.ChangeMemberInfo;
import GraduationProject.TripPlannerZ.delete.MemberLogin;
-import GraduationProject.TripPlannerZ.dto.member.MemberTrip;
-import GraduationProject.TripPlannerZ.dto.member.MyPage;
import GraduationProject.TripPlannerZ.service.*;
import GraduationProject.TripPlannerZ.service.TripService;
import GraduationProject.TripPlannerZ.sseEmitter.SseEmitterService;
+import GraduationProject.TripPlannerZ.util.RedisUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import lombok.RequiredArgsConstructor;
@@ -38,12 +34,10 @@
public class MemberController {
private final MemberService memberService;
- private final LoginService loginService;
- private final TripService tripService;
private final MemberPreferenceService memberPreferenceService;
private final UserAuthProvider userAuthProvider;
private final SseEmitterService sseEmitterService;
- private final PartyService partyService;
+ private final AuthService authService;
@@ -81,12 +75,10 @@ public SseEmitter subscribe() {
}
- @GetMapping("/members/logout")
- public void logout(HttpServletRequest request) {
- HttpSession session = request.getSession(false);
-
- if (session != null)
- session.invalidate();
+ @PostMapping("/members/logout")
+ public void logout(@RequestBody BlackList blackList) {
+ System.out.println("blackList.getToken() = " + blackList.getToken());
+ authService.logout(blackList.getToken());
}
@GetMapping("/members/tripInfo")
diff --git a/src/main/java/GraduationProject/TripPlannerZ/dto/member/BlackList.java b/src/main/java/GraduationProject/TripPlannerZ/dto/member/BlackList.java
new file mode 100644
index 00000000..61fab027
--- /dev/null
+++ b/src/main/java/GraduationProject/TripPlannerZ/dto/member/BlackList.java
@@ -0,0 +1,13 @@
+package GraduationProject.TripPlannerZ.dto.member;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class BlackList {
+
+ private String token;
+}
diff --git a/src/main/java/GraduationProject/TripPlannerZ/service/AuthService.java b/src/main/java/GraduationProject/TripPlannerZ/service/AuthService.java
new file mode 100644
index 00000000..1668cf9c
--- /dev/null
+++ b/src/main/java/GraduationProject/TripPlannerZ/service/AuthService.java
@@ -0,0 +1,16 @@
+package GraduationProject.TripPlannerZ.service;
+
+import GraduationProject.TripPlannerZ.util.RedisUtil;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class AuthService {
+
+ private final RedisUtil redisUtil;
+
+ public void logout(String accessToken) {
+ redisUtil.setBlackList(accessToken, "BlackList", 3_600_000);
+ }
+}
diff --git a/src/main/java/GraduationProject/TripPlannerZ/util/RedisUtil.java b/src/main/java/GraduationProject/TripPlannerZ/util/RedisUtil.java
index eac82a83..8b3e9ff0 100644
--- a/src/main/java/GraduationProject/TripPlannerZ/util/RedisUtil.java
+++ b/src/main/java/GraduationProject/TripPlannerZ/util/RedisUtil.java
@@ -14,6 +14,7 @@
public class RedisUtil {
private final StringRedisTemplate redisTemplate;
+ private final StringRedisTemplate blackList;
public String getData(String key) {
ValueOperations valueOperations = redisTemplate.opsForValue();
@@ -27,6 +28,12 @@ public void setDataExpire(String key, String value, long duration) {
valueOperations.set(key, value, expireDuration);
}
+ public void setBlackList(String key, String value, long duration) {
+ ValueOperations valueOperations = blackList.opsForValue();
+ Duration expireDuration = Duration.ofSeconds(duration);
+ valueOperations.set(key, "BlackList", expireDuration);
+ }
+
public void deleteData(String key) {
// 데이터 삭제
redisTemplate.delete(key);
@@ -36,4 +43,8 @@ public boolean existData(String key) {
return Boolean.TRUE.equals(redisTemplate.hasKey(key));
}
+ public boolean existBlackList(String key) {
+ return Boolean.TRUE.equals(blackList.hasKey(key));
+ }
+
}
|