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