Skip to content

Commit

Permalink
Merge branch 'shinhee'
Browse files Browse the repository at this point in the history
  • Loading branch information
shinheekim committed Jul 23, 2024
2 parents f4f2e4d + 659bf44 commit bbd92fe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.httpBasic(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(authorize -> authorize
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.requestMatchers("/csrf-token").permitAll()
.requestMatchers(HttpMethod.POST, "/users/join").permitAll() // 모든 사용자 회원가입 엔드포인트 허용
.requestMatchers(HttpMethod.POST, "/users/login").permitAll() // 모든 사용자 회원가입 엔드포인트 허용
.requestMatchers(HttpMethod.GET, "/users").authenticated()
.anyRequest().permitAll()
.requestMatchers(HttpMethod.POST, "/users/**").permitAll() // 모든 사용자 회원가입 엔드포인트 허용
.anyRequest().authenticated()
)
.addFilterBefore(jwtAuthorizationFilter, UsernamePasswordAuthenticationFilter.class)
.sessionManagement(sessionManagement -> sessionManagement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import org.springframework.http.HttpStatus;

// 응답 템플릿
@Getter
public class RspTemplate<T> {
int statusCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.skhu.likelion12thteam03be.user.api.dto.request.UserLoginReqDto;
import net.skhu.likelion12thteam03be.user.api.dto.request.UserSaveReqDto;
import net.skhu.likelion12thteam03be.user.api.dto.response.UserLoginResDto;
import net.skhu.likelion12thteam03be.user.domain.Role;
import net.skhu.likelion12thteam03be.user.domain.User;
import net.skhu.likelion12thteam03be.user.domain.repository.UserRepository;
import net.skhu.likelion12thteam03be.user.exception.InvalidUserException;
Expand All @@ -31,6 +32,7 @@ public void join(UserSaveReqDto userSaveReqDto) {
.loginId(userSaveReqDto.loginId())
.password(passwordEncoder.encode(userSaveReqDto.password()))
.nickname(userSaveReqDto.nickname())
.role(Role.ROLE_USER)
.build();
userRepository.save(user);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net.skhu.likelion12thteam03be.user.domain;

public enum Role {
ROLE_ADMIN, ROLE_USER
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ public class User {
private String password;
private String nickname;

@Enumerated(EnumType.STRING)
private Role role;

/* @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Post> posts = new ArrayList<>();*/

@Builder
public User(String loginId, String password, String nickname) {
public User(String loginId, String password, String nickname, Role role) {
validateNickname(nickname);
this.loginId = loginId;
this.password = password;
this.nickname = nickname;
this.role = role;
}

private void validateNickname(String nickname) {
Expand Down

0 comments on commit bbd92fe

Please sign in to comment.