id 찾기 기능 추가.
parent
51b5907916
commit
f379513681
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import React, {useState, useEffect, useRef, useCallback} from 'react';
|
||||
import {Link, useLocation, useNavigate} from 'react-router-dom';
|
||||
import * as EgovNet from 'api/egovFetch';
|
||||
import {parseJwt} from "../../utils/parseJwt";
|
||||
|
|
@ -22,7 +22,7 @@ function EgovLoginContent(props) {
|
|||
const location = useLocation();
|
||||
console.log("EgovLoginContent [location] : ", location);
|
||||
|
||||
const [userInfo, setUserInfo] = useState({ username: '', password: 'default', userSe: 'USR' });
|
||||
const [userInfo, setUserInfo] = useState({ username: '', password: 'default', email: '', userSe: 'USR'});
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
||||
const [saveIDFlag, setSaveIDFlag] = useState(false);
|
||||
|
|
@ -64,7 +64,7 @@ function EgovLoginContent(props) {
|
|||
useEffect(() => {
|
||||
let data = getLocalItem(KEY_ID);
|
||||
if (data !== null) {
|
||||
setUserInfo({ username: data, password: 'default', userSe: 'USR' });
|
||||
setUserInfo({ username: data, password: 'default', email: '', userSe: 'USR' });
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
@ -108,11 +108,13 @@ function EgovLoginContent(props) {
|
|||
})
|
||||
}
|
||||
|
||||
const idFindModal = () => {
|
||||
const idFindModal = useCallback(
|
||||
()=> {
|
||||
setModalTitle("ID 찾기")
|
||||
setModalBody(IdFindForm)
|
||||
handleShow();
|
||||
}
|
||||
)
|
||||
const pwFindModal = () => {
|
||||
setModalTitle("PW 찾기")
|
||||
setModalBody(PwFindForm)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,47 @@
|
|||
|
||||
import * as EgovNet from "../../api/egovFetch";
|
||||
import CODE from "../../constants/code";
|
||||
|
||||
import Row from "react-bootstrap/Row";
|
||||
import Col from "react-bootstrap/Col";
|
||||
import Form from "react-bootstrap/Form";
|
||||
import Button from "react-bootstrap/Button";
|
||||
import {setLocalItem} from "../../utils/storage";
|
||||
|
||||
|
||||
function IdFindForm(){
|
||||
|
||||
const findId = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const form = e.currentTarget;
|
||||
if(!form.email.value){
|
||||
alert("이메일을 입력해주세요.")
|
||||
}else{
|
||||
EgovNet.requestFetch(
|
||||
"/auth/findId",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({email: form.email.value})
|
||||
},
|
||||
(resp) => {
|
||||
alert(resp.resultMessage)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Form>
|
||||
<Form onSubmit={findId} noValidate>
|
||||
<Form.Group as={Row} className="mb-3" controlId="formHorizontalEmail">
|
||||
<Form.Label column sm={2}>
|
||||
이메일
|
||||
</Form.Label>
|
||||
<Col sm={10}>
|
||||
<Form.Control type="email" placeholder="Email" />
|
||||
<Form.Control type="email" placeholder="Email" name="email" required />
|
||||
<Form.Control.Feedback type={"invalid"} >메일을 입력해주세요.</Form.Control.Feedback>
|
||||
</Col>
|
||||
</Form.Group>
|
||||
<Form.Group as={Row} className="mb-3">
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function PwFindForm(){
|
|||
아이디
|
||||
</Form.Label>
|
||||
<Col sm={10}>
|
||||
<Form.Control type="email" placeholder="Email" />
|
||||
<Form.Control type="text" placeholder="ID" />
|
||||
</Col>
|
||||
</Form.Group>
|
||||
<Form.Group as={Row} className="mb-3" controlId="formHorizontalEmail">
|
||||
|
|
|
|||
|
|
@ -107,6 +107,31 @@ public class EgovLoginApiController extends BaseController {
|
|||
return resultMap;
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "아이디 찾기",
|
||||
description = "아이디 찾기",
|
||||
tags = {"EgovLoginApiController"}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||
@ApiResponse(responseCode = "300", description = "조회 실패")
|
||||
})
|
||||
@PostMapping(value = "/findId")
|
||||
public HashMap<String, Object> findId(@RequestBody LoginVO loginVO) throws Exception {
|
||||
HashMap<String, Object> resultMap = new HashMap<String, Object>();
|
||||
|
||||
String userId = loginService.selectEmail(loginVO);
|
||||
if(userId!=null){
|
||||
userId = userId.substring(0, userId.length()-3)+"***";
|
||||
resultMap.put("resultCode", ResponseCode.SUCCESS.getCode());
|
||||
resultMap.put("resultMessage", "아이디는 "+userId+" 입니다.");
|
||||
}else{
|
||||
resultMap.put("resultCode", ResponseCode.SAVE_ERROR.getCode());
|
||||
resultMap.put("resultMessage", "이메일 조회에 실패하였습니다.");
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@RequestMapping("/accessTokenRefresh")
|
||||
public HashMap<String, Object> accessTokenRefresh(HttpServletRequest request, HttpServletResponse response, @AuthenticationPrincipal UserInfo loginVO){
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ import java.util.Optional;
|
|||
public interface UserInfoRepository extends JpaRepository<UserInfo, Integer> {
|
||||
|
||||
Optional<UserInfo> findByUserId(String userId);
|
||||
Optional<UserInfo> findByEmail(String email);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,6 @@ public interface EgovLoginService {
|
|||
public boolean searchPassword(LoginVO vo) throws Exception;
|
||||
|
||||
public Integer insertUser(LoginVO loginVO);
|
||||
|
||||
String selectEmail(LoginVO loginVO);
|
||||
}
|
||||
|
|
@ -46,6 +46,10 @@ public class EgovLoginServiceImpl extends EgovAbstractServiceImpl implements Ego
|
|||
|
||||
@Transactional
|
||||
public Integer insertUser(LoginVO loginVO){
|
||||
UserInfo savedUser = userInfoRepository.findByUserId(loginVO.getId()).orElse(null);
|
||||
if(savedUser == null){
|
||||
savedUser = userInfoRepository.findByEmail(loginVO.getEmail()).orElse(null);
|
||||
if (savedUser == null){
|
||||
UserInfo info = new UserInfo();
|
||||
info.setUserId(loginVO.getId());
|
||||
info.setPassword(convertPassword(loginVO.getPassword()));
|
||||
|
|
@ -54,6 +58,14 @@ public class EgovLoginServiceImpl extends EgovAbstractServiceImpl implements Ego
|
|||
userInfoRepository.save(info);
|
||||
return info.getUserSeq();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String selectEmail(LoginVO loginVO){
|
||||
UserInfo savedUser = userInfoRepository.findByEmail(loginVO.getEmail()).orElse(null);
|
||||
return savedUser==null?null:savedUser.getUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundException {
|
||||
|
|
|
|||
|
|
@ -60,10 +60,12 @@ public class SecurityConfig {
|
|||
// 인증 예외 List
|
||||
private String[] AUTH_WHITELIST = {
|
||||
"/",
|
||||
"/auth/login",
|
||||
"/login",
|
||||
"/auth/login",
|
||||
"/auth/accessTokenRefresh", // jwt accessToken 갱신
|
||||
"/auth/join",//회원가입
|
||||
"/auth/findId", // id 찾기
|
||||
"/auth/findPw", // pw 찾기
|
||||
"/cmm/main/**.do", // 메인페이지
|
||||
"/cmm/fms/FileDown.do", //파일 다운로드
|
||||
"/cmm/fms/getImage.do", //갤러리 이미지보기
|
||||
|
|
|
|||
Loading…
Reference in New Issue