Skip to content

Commit

Permalink
Merge pull request #22 from SafeNet-2024/feature/receipt
Browse files Browse the repository at this point in the history
와 μˆ˜κ³ ν•˜μ…¨μ–΄μš”!! πŸ‘πŸ»
  • Loading branch information
khee2 authored Jun 9, 2024
2 parents e2d4e5d + 347c9ba commit b11cf3e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,25 @@ public ResponseEntity<TokenResponseDto> login(@RequestBody LoginRequestDto login

@PostMapping(value = "/logout")
@Operation(summary = "λ‘œκ·Έμ•„μ›ƒ", description = "JWt 토큰을 redisμ—μ„œ μ‚­μ œν•©λ‹ˆλ‹€")
public ResponseEntity<Void> logout( @RequestHeader(name = "ACCESS_TOKEN", required = false) String accessToken,
public ResponseEntity<LogoutResponseDto> logout( @RequestHeader(name = "ACCESS_TOKEN", required = false) String accessToken,
@RequestHeader(name = "REFRESH_TOKEN", required = false) String refreshToken) {
String message = "";
HttpStatus status = HttpStatus.OK;
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserDetailsImpl userDetails = (UserDetailsImpl) principal;
String email = userDetails.getUsername();
log.info("ν† ν°μœΌλ‘œλΆ€ν„° 이메일을 μΆ”μΆœν•˜μ˜€μŠ΅λ‹ˆλ‹€.: "+email);
memberService.logout(email, accessToken);
return ResponseEntity.ok().build();
try {
memberService.logout(email, accessToken);
message ="λ‘œκ·Έμ•„μ›ƒμ„ μ„±κ³΅μ μœΌλ‘œ μ™„λ£Œν–ˆμŠ΅λ‹ˆλ‹€.";
} catch (Exception ex){
throw new CustomException("λ‘œκ·Έμ•„μ›ƒκ³Όμ • 쀑 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. : "+ ex.getMessage());
}
LogoutResponseDto logoutResponseDto
= LogoutResponseDto.builder().
result(message).
build();
return ResponseEntity.status(status).body(logoutResponseDto);
}

@PatchMapping("/address")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.SafeNet.Backend.domain.member.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;

@Builder
@Data
@AllArgsConstructor
@ToString
@Schema(description ="λ‘œκ·Έμ•„μ›ƒ Dto")
public class LogoutResponseDto {
@Schema(description = "λ‘œκ·Έμ•„μ›ƒ κ²°κ³Ό", required = true, example = "λ‘œκ·Έμ•„μ›ƒμ— μ„±κ³΅ν–ˆμŠ΅λ‹ˆλ‹€.")
@NotNull
String result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
import com.SafeNet.Backend.global.auth.JwtTokenProvider;
import com.SafeNet.Backend.global.exception.JwtAccessDeniedHandler;
import com.SafeNet.Backend.global.exception.JwtAuthenticationEntryPoint;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
Expand Down Expand Up @@ -59,10 +56,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers("/", "/api/auth/**", "/swagger-ui/**", "/v3/api-docs/**", "/s3/test", "/ws-stomp/**").permitAll() // νŠΉμ • κ²½λ‘œμ— λŒ€ν•œ μ ‘κ·Ό ν—ˆμš©
// .requestMatchers(HttpMethod.GET,"/api/v2/posts/{postId}").permitAll() // GET μš”μ²­ ν—ˆμš©
.anyRequest().authenticated()) // λ‚˜λ¨Έμ§€ μš”μ²­μ€ 인증 ν•„μš”
//.formLogin(form -> form
// .loginPage("/login").permitAll()) // 둜그인 νŽ˜μ΄μ§€ μ„€μ •
//.logout(logout -> logout
// .logoutSuccessUrl("/").permitAll()) // λ‘œκ·Έμ•„μ›ƒ μ„±κ³΅μ‹œ λ¦¬λ‹€μ΄λ ‰μ…˜ μ„€μ •
.exceptionHandling(authenticationManager -> authenticationManager
.accessDeniedHandler(jwtAccessDeniedHandler)
.authenticationEntryPoint(jwtAuthenticationEntryPoint))
Expand Down

0 comments on commit b11cf3e

Please sign in to comment.