Skip to content

Commit

Permalink
Merge pull request #23 from TEAM-DHS/feat/member
Browse files Browse the repository at this point in the history
[FEAT] 멤버 정보 조회 API
  • Loading branch information
xyzwv authored Nov 13, 2023
2 parents 43b96b3 + b392701 commit 040b729
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import com.efub.dhs.domain.member.dto.AuthRequestDto;
import com.efub.dhs.domain.member.dto.AuthResponseDto;
import com.efub.dhs.domain.member.dto.SignUpResponseDto;
import com.efub.dhs.domain.member.dto.ProfileResponseDto;
import com.efub.dhs.domain.member.entity.Member;
import com.efub.dhs.domain.member.service.AuthService;
import com.efub.dhs.global.jwt.entity.JwtToken;
Expand All @@ -32,9 +32,9 @@ public class AuthController {

@PostMapping("/signup")
@ResponseStatus(HttpStatus.CREATED)
public SignUpResponseDto signUp(@RequestBody @Valid AuthRequestDto requestDto) {
public ProfileResponseDto signUp(@RequestBody @Valid AuthRequestDto requestDto) {
Member member = authService.signUp(requestDto.getUsername(), requestDto.getPassword());
return new SignUpResponseDto(member.getMemberId(), member.getUsername());
return new ProfileResponseDto(member.getUsername());
}

@PostMapping("/login")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.efub.dhs.domain.member.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.efub.dhs.domain.member.dto.ProfileResponseDto;
import com.efub.dhs.global.utils.SecurityUtils;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
public class MemberController {

@GetMapping("/members/me")
public ProfileResponseDto getProfile() {
return new ProfileResponseDto(SecurityUtils.getCurrentUsername());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

@Getter
@AllArgsConstructor
public class SignUpResponseDto {
public class ProfileResponseDto {

private final Long memberId;
private final String username;
}
5 changes: 3 additions & 2 deletions src/main/java/com/efub/dhs/global/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import lombok.RequiredArgsConstructor;

@Configuration
@EnableWebSecurity
@EnableWebSecurity(debug = true)
@RequiredArgsConstructor
public class SecurityConfig {

Expand All @@ -32,8 +32,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers(HttpMethod.GET).permitAll()
.antMatchers("/members/**").authenticated()
.antMatchers("/auth/**").permitAll()
.antMatchers(HttpMethod.GET).permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(new JwtFilter(jwtAuthProvider), UsernamePasswordAuthenticationFilter.class)
Expand Down

0 comments on commit 040b729

Please sign in to comment.