비밀번호 재설정
This commit is contained in:
parent
7b32de158b
commit
74272f3233
@ -41,6 +41,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.context.SecurityContextHolderStrategy;
|
||||
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -63,60 +64,109 @@ public class UserController {
|
||||
private final NetmemberService netmemberservice;
|
||||
|
||||
/**
|
||||
* 사용 가능 색상 조회
|
||||
*
|
||||
* @return ApiResponse<List<MapDto>>
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/color")
|
||||
public ApiResponse<List<MapDto>> getColorList() {
|
||||
List<MapDto> ColorList = commoncodservice.getColorList();
|
||||
return ApiResponse.ok(ColorList);
|
||||
}
|
||||
* 사용 가능 색상 조회
|
||||
*
|
||||
* @return ApiResponse<List<MapDto>>
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/color")
|
||||
public ApiResponse<List<MapDto>> getColorList() {
|
||||
List<MapDto> ColorList = commoncodservice.getColorList();
|
||||
return ApiResponse.ok(ColorList);
|
||||
}
|
||||
|
||||
/**
|
||||
* MBTI 목록 조회
|
||||
*
|
||||
* @return ApiResponse<List<MapDto>>
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/mbti")
|
||||
public ApiResponse<List<MapDto>> getMbtiList() {
|
||||
List<MapDto> MbtiList = commoncodservice.getMbtiList();
|
||||
return ApiResponse.ok(MbtiList);
|
||||
}
|
||||
/**
|
||||
* MBTI 목록 조회
|
||||
*
|
||||
* @return ApiResponse<List<MapDto>>
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/mbti")
|
||||
public ApiResponse<List<MapDto>> getMbtiList() {
|
||||
List<MapDto> MbtiList = commoncodservice.getMbtiList();
|
||||
return ApiResponse.ok(MbtiList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 회원가입
|
||||
*
|
||||
* @param profile
|
||||
* @param map
|
||||
* @return ApiResponse<Integer>
|
||||
* @throws RuntimeException 파일 업로드 실패 시
|
||||
*/
|
||||
@PostMapping("/join")
|
||||
public ApiResponse<Integer> register(@RequestParam("memberPrf") MultipartFile memberPrf, @ReqMap MapDto map) {
|
||||
int member = netmemberservice.register(memberPrf, map);
|
||||
return ApiResponse.ok(member);
|
||||
}
|
||||
/**
|
||||
* 비밀번호 힌트 목록 조회
|
||||
*
|
||||
* @return ApiResponse<List<MapDto>>
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/pwhint")
|
||||
public ApiResponse<List<MapDto>> getPwhintList() {
|
||||
List<MapDto> PwhintList = commoncodservice.getPwhintList();
|
||||
return ApiResponse.ok(PwhintList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 아이디 중복 체크
|
||||
*
|
||||
* @param memberIds
|
||||
* @return ApiResponse<Boolean>
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@GetMapping("/checkId")
|
||||
public ApiResponse<Boolean> selectCheckId(@RequestParam String memberIds) {
|
||||
boolean isDuplicate = netmemberservice.selectCheckId(memberIds);
|
||||
return ApiResponse.ok(!isDuplicate);
|
||||
}
|
||||
/**
|
||||
* 회원가입
|
||||
*
|
||||
* @param profile
|
||||
* @param map
|
||||
* @return ApiResponse<Integer>
|
||||
* @throws RuntimeException 파일 업로드 실패 시
|
||||
*/
|
||||
@PostMapping("/join")
|
||||
public ApiResponse<Integer> register(@RequestParam("memberPrf") MultipartFile memberPrf, @ReqMap MapDto map) {
|
||||
int member = netmemberservice.register(memberPrf, map);
|
||||
return ApiResponse.ok(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* 아이디 중복 체크
|
||||
*
|
||||
* @param memberIds
|
||||
* @return ApiResponse<Boolean>
|
||||
*
|
||||
*/
|
||||
@GetMapping("/checkId")
|
||||
public ApiResponse<Boolean> selectCheckId(@RequestParam String memberIds) {
|
||||
boolean isDuplicate = netmemberservice.selectCheckId(memberIds);
|
||||
return ApiResponse.ok(!isDuplicate);
|
||||
}
|
||||
|
||||
//security 인증 체크
|
||||
/**
|
||||
* 로그인 여부 체크
|
||||
*
|
||||
* @return ApiResponse<Boolean>
|
||||
*/
|
||||
@GetMapping("/isLogin")
|
||||
public ApiResponse<Boolean> checkLogin() {
|
||||
boolean isLoggedIn = AuthUtil.isLoggedIn();
|
||||
return ApiResponse.ok(isLoggedIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀번호 재설정 member 체크
|
||||
*
|
||||
* @param map
|
||||
* @return ApiResponse<Boolean>
|
||||
*
|
||||
*/
|
||||
@PostMapping("/pwReset")
|
||||
public ApiResponse<Boolean> selectPwReset(@ReqMap MapDto map) {
|
||||
boolean isPwReset = netmemberservice.selectPwReset(map);
|
||||
return ApiResponse.ok(isPwReset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀번호 재설정
|
||||
*
|
||||
* @param map
|
||||
* @return ApiResponse<Boolean>
|
||||
*
|
||||
*/
|
||||
@PatchMapping("/pwNew")
|
||||
public ApiResponse<Boolean> updatePassword(@ReqMap MapDto map) {
|
||||
boolean isPwNew = netmemberservice.updatePassword(map);
|
||||
return ApiResponse.ok(isPwNew);
|
||||
}
|
||||
|
||||
// security 인증 체크
|
||||
@GetMapping("userInfo")
|
||||
public ApiResponse<MemberVo> getUserInfo(@AuthenticationPrincipal MemberVo memberVo) {
|
||||
SecurityContextHolderStrategy contextHolderStrategy = SecurityContextHolder.getContextHolderStrategy();
|
||||
@ -133,9 +183,9 @@ public class UserController {
|
||||
return ApiResponse.ok(memberVo);
|
||||
}
|
||||
|
||||
//유저 세션 체크
|
||||
// 유저 세션 체크
|
||||
@GetMapping(value = "check")
|
||||
public ApiResponse<?> check(){
|
||||
public ApiResponse<?> check() {
|
||||
Map<String, HttpSession> sessions = SessionListener.getSessions();
|
||||
Map<String, Object> sessionData = new HashMap<>();
|
||||
|
||||
@ -172,10 +222,7 @@ public class UserController {
|
||||
return ApiResponse.ok(remember);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//로그아웃
|
||||
// 로그아웃
|
||||
@Guest
|
||||
@GetMapping("/logout")
|
||||
public ApiResponse<String> logout(HttpServletRequest request, HttpServletResponse response) {
|
||||
@ -198,20 +245,19 @@ public class UserController {
|
||||
|
||||
return ApiResponse.ok(returnMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 목록 전체 조회
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/allUserList")
|
||||
public ApiResponse<List<MapDto>> getallUserList() {
|
||||
List<MapDto> allUserList = netmemberservice.getallUserList();
|
||||
return ApiResponse.ok(allUserList);
|
||||
}
|
||||
|
||||
|
||||
* 사원 목록 전체 조회
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/allUserList")
|
||||
public ApiResponse<List<MapDto>> getallUserList() {
|
||||
List<MapDto> allUserList = netmemberservice.getallUserList();
|
||||
return ApiResponse.ok(allUserList);
|
||||
}
|
||||
|
||||
@Guest
|
||||
@GetMapping("get1")
|
||||
|
||||
@ -32,5 +32,10 @@ public interface NetmemberMapper {
|
||||
|
||||
int selectCheckId(String memberIds);
|
||||
|
||||
int selectPwReset(MapDto map);
|
||||
|
||||
int updatePassword(MapDto map);
|
||||
|
||||
List<MapDto> getallUserList();
|
||||
|
||||
}
|
||||
|
||||
@ -36,64 +36,92 @@ public class NetmemberService {
|
||||
private final FileService fileService;
|
||||
|
||||
/**
|
||||
* 회원 가입
|
||||
*
|
||||
* @param profile
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public int register(MultipartFile memberPrf, MapDto map) {
|
||||
// 프로필 이미지 저장, 저장된 경로 가져옴
|
||||
String profilePath = fileService.uploadFile(memberPrf);
|
||||
map.put("memberPrf", profilePath);
|
||||
* 회원 가입
|
||||
*
|
||||
* @param profile
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public int register(MultipartFile memberPrf, MapDto map) {
|
||||
// 프로필 이미지 저장, 저장된 경로 가져옴
|
||||
String profilePath = fileService.uploadFile(memberPrf);
|
||||
map.put("memberPrf", profilePath);
|
||||
|
||||
// 비밀번호 암호화 및 저장
|
||||
String encodedPassword = passwordEncoder.encode(map.getString("memberPwd"));
|
||||
map.put("memberPwd", encodedPassword);
|
||||
// 비밀번호 암호화 및 저장
|
||||
String encodedPassword = passwordEncoder.encode(map.getString("memberPwd"));
|
||||
map.put("memberPwd", encodedPassword);
|
||||
|
||||
// 회원 기본 정보 설정
|
||||
map.put("memberRol", "ROLE_MEMBER");
|
||||
map.put("memberPos", 500107);
|
||||
map.put("memberTkn", "Null");
|
||||
map.put("memberPrm", "Y");
|
||||
map.put("memberDel", "N");
|
||||
map.put("memberLea", "N");
|
||||
map.put("memberRdt", LocalDateTime.now());
|
||||
map.put("memberCdt", LocalDateTime.now());
|
||||
// 회원 기본 정보 설정
|
||||
map.put("memberRol", "ROLE_MEMBER");
|
||||
map.put("memberPos", 500107);
|
||||
map.put("memberTkn", "Null");
|
||||
map.put("memberPrm", "Y");
|
||||
map.put("memberDel", "N");
|
||||
map.put("memberLea", "N");
|
||||
map.put("memberRdt", LocalDateTime.now());
|
||||
map.put("memberCdt", LocalDateTime.now());
|
||||
|
||||
// 회원 정보 저장
|
||||
int result = memberMapper.insertMember(map);
|
||||
// 회원 정보 저장
|
||||
int result = memberMapper.insertMember(map);
|
||||
|
||||
// 선택한 색상 코드 사용 처리
|
||||
String color = map.getString("memberCol");
|
||||
commoncodMapper.updateColorYon(color);
|
||||
// 선택한 색상 코드 사용 처리
|
||||
String color = map.getString("memberCol");
|
||||
commoncodMapper.updateColorYon(color);
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 아이디 중복 체크
|
||||
*
|
||||
* @param memberIds
|
||||
* @return
|
||||
*/
|
||||
public boolean selectCheckId(String memberIds) {
|
||||
return memberMapper.selectCheckId(memberIds) > 0;
|
||||
}
|
||||
/**
|
||||
* 아이디 중복 체크
|
||||
*
|
||||
* @param memberIds
|
||||
* @return
|
||||
*/
|
||||
public boolean selectCheckId(String memberIds) {
|
||||
return memberMapper.selectCheckId(memberIds) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 목록 전체 조회
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 사원 목록 전체 조회
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public List<MapDto> getallUserList() {
|
||||
return memberMapper.getallUserList();
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
/**
|
||||
* 로그인 토큰
|
||||
*
|
||||
* @param id, token
|
||||
* @return
|
||||
*/
|
||||
public void updateMemberToken(String id, String token) {
|
||||
memberMapper.updateMemberToken(id, token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀번호 재설정 member 체크
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public boolean selectPwReset(MapDto map) {
|
||||
return memberMapper.selectPwReset(map) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 비밀번호 재설정
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public boolean updatePassword(MapDto map) {
|
||||
String encodedPassword = passwordEncoder.encode(map.getString("password"));
|
||||
map.put("password", encodedPassword);
|
||||
System.out.println("암호화된 비밀번호: " + encodedPassword);
|
||||
return memberMapper.updatePassword(map) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -95,6 +95,23 @@
|
||||
WHERE MEMBERIDS = #{memberIds}
|
||||
</select>
|
||||
|
||||
<!-- 비밀번호 재설정 member 체크 -->
|
||||
<select id="selectPwReset" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
FROM netmember
|
||||
WHERE MEMBERIDS = #{id}
|
||||
AND MEMBERBTH = #{birth}
|
||||
AND MEMBERPWH = #{pwhint}
|
||||
AND MEMBERPWR = #{pwhintRes}
|
||||
</select>
|
||||
|
||||
<!-- 비밀번호 재설정 -->
|
||||
<update id="updatePassword">
|
||||
UPDATE netmember
|
||||
SET MEMBERPWD = #{password}
|
||||
WHERE MEMBERIDS = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getallUserList" resultType="Map">
|
||||
SELECT *
|
||||
FROM
|
||||
|
||||
Loading…
Reference in New Issue
Block a user