회원관리 관리 수정
This commit is contained in:
@@ -56,6 +56,10 @@ public class AuthController {
|
||||
@ApiResponse(
|
||||
responseCode = "401",
|
||||
description = "ID 또는 비밀번호 불일치",
|
||||
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
|
||||
@ApiResponse(
|
||||
responseCode = "400",
|
||||
description = "미사용 상태",
|
||||
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
|
||||
})
|
||||
public ApiResponseDto<TokenResponse> signin(
|
||||
@@ -65,6 +69,12 @@ public class AuthController {
|
||||
@RequestBody
|
||||
SignInRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
||||
//
|
||||
if (authService.existsUsername(request)) {
|
||||
// return
|
||||
}
|
||||
|
||||
Authentication authentication =
|
||||
authenticationManager.authenticate(
|
||||
new UsernamePasswordAuthenticationToken(request.getUsername(), request.getPassword()));
|
||||
|
||||
@@ -49,12 +49,12 @@ public class MembersApiController {
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "비밀번호 초기화", description = "비밀번호 초기화")
|
||||
@Operation(summary = "사용자 비밀번호 변경", description = "사용자 비밀번호 변경")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "201",
|
||||
description = "비밀번호 초기화",
|
||||
description = "사용자 비밀번호 변경",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.kamco.cd.kamcoback.members.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MemberEntity;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class MemberDetails implements UserDetails {
|
||||
|
||||
private final MemberEntity member;
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
// TODO: tb_member_role 에서 역할 꺼내서 권한으로 변환하고 싶으면 여기 구현
|
||||
// 예시 (나중에 MemberRoleEntity 보고 수정):
|
||||
// return member.getTbMemberRoles().stream()
|
||||
// .map(role -> new SimpleGrantedAuthority("ROLE_" + role.getRoleName()))
|
||||
// .toList();
|
||||
|
||||
return List.of(); // 일단 빈 권한 리스트
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return member.getPassword(); // 암호화된 비밀번호
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
// 로그인 ID 로 무엇을 쓸지 선택
|
||||
// 1) 이메일 로그인:
|
||||
return member.getUserId();
|
||||
|
||||
// 2) 사번으로 로그인하고 싶으면:
|
||||
// return member.getEmployeeNo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
// status 가 ACTIVE 일 때만 로그인 허용
|
||||
return "ACTIVE".equalsIgnoreCase(member.getStatus());
|
||||
}
|
||||
|
||||
public MemberEntity getMember() {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
@@ -151,8 +151,13 @@ public class MembersDto {
|
||||
@Setter
|
||||
public static class InitReq {
|
||||
|
||||
@Schema(description = "패스워드", example = "")
|
||||
@Schema(description = "변경 패스워드", example = "")
|
||||
@Size(max = 255)
|
||||
@NotBlank
|
||||
private String password;
|
||||
|
||||
@Schema(description = "초기 패스워드", example = "")
|
||||
@NotBlank
|
||||
private String tempPassword;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,15 @@ public class MemberException {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PasswordNotFoundException extends RuntimeException {
|
||||
|
||||
public PasswordNotFoundException() {
|
||||
super("Password not found");
|
||||
}
|
||||
|
||||
public PasswordNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.members.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.members.dto.SignInRequest;
|
||||
import com.kamco.cd.kamcoback.postgres.core.MembersCoreService;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -32,4 +33,8 @@ public class AuthService {
|
||||
public void loginFail(UUID uuid) {
|
||||
membersCoreService.loginFail(uuid);
|
||||
}
|
||||
|
||||
public boolean existsUsername(SignInRequest request) {
|
||||
return membersCoreService.existsUsername(request);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user