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 {Link, useLocation, useNavigate} from 'react-router-dom';
|
||||||
import * as EgovNet from 'api/egovFetch';
|
import * as EgovNet from 'api/egovFetch';
|
||||||
import {parseJwt} from "../../utils/parseJwt";
|
import {parseJwt} from "../../utils/parseJwt";
|
||||||
|
|
@ -22,8 +22,8 @@ function EgovLoginContent(props) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
console.log("EgovLoginContent [location] : ", location);
|
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
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
||||||
const [saveIDFlag, setSaveIDFlag] = useState(false);
|
const [saveIDFlag, setSaveIDFlag] = useState(false);
|
||||||
|
|
||||||
|
|
@ -37,17 +37,17 @@ function EgovLoginContent(props) {
|
||||||
|
|
||||||
const KEY_ID = "KEY_ID";
|
const KEY_ID = "KEY_ID";
|
||||||
const KEY_SAVE_ID_FLAG = "KEY_SAVE_ID_FLAG";
|
const KEY_SAVE_ID_FLAG = "KEY_SAVE_ID_FLAG";
|
||||||
|
|
||||||
const handleSaveIDFlag = () => {
|
const handleSaveIDFlag = () => {
|
||||||
setLocalItem(KEY_SAVE_ID_FLAG, !saveIDFlag)
|
setLocalItem(KEY_SAVE_ID_FLAG, !saveIDFlag)
|
||||||
setSaveIDFlag(!saveIDFlag);
|
setSaveIDFlag(!saveIDFlag);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let idFlag = getLocalItem(KEY_SAVE_ID_FLAG);
|
let idFlag = getLocalItem(KEY_SAVE_ID_FLAG);
|
||||||
if (idFlag === null) {
|
if (idFlag === null) {
|
||||||
setSaveIDFlag(false);
|
setSaveIDFlag(false);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
idFlag = false;
|
idFlag = false;
|
||||||
} else {
|
} else {
|
||||||
setSaveIDFlag(idFlag);
|
setSaveIDFlag(idFlag);
|
||||||
|
|
@ -64,13 +64,13 @@ function EgovLoginContent(props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let data = getLocalItem(KEY_ID);
|
let data = getLocalItem(KEY_ID);
|
||||||
if (data !== null) {
|
if (data !== null) {
|
||||||
setUserInfo({ username: data, password: 'default', userSe: 'USR' });
|
setUserInfo({ username: data, password: 'default', email: '', userSe: 'USR' });
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const submitFormHandler = (e) => {
|
const submitFormHandler = (e) => {
|
||||||
console.log("EgovLoginContent submitFormHandler()");
|
console.log("EgovLoginContent submitFormHandler()");
|
||||||
|
|
||||||
const loginUrl = "/auth/login"
|
const loginUrl = "/auth/login"
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
@ -101,18 +101,20 @@ function EgovLoginContent(props) {
|
||||||
document.querySelector('.all_menu.WEB').classList.add('closed');
|
document.querySelector('.all_menu.WEB').classList.add('closed');
|
||||||
document.querySelector('.btnAllMenu').classList.remove('active');
|
document.querySelector('.btnAllMenu').classList.remove('active');
|
||||||
document.querySelector('.btnAllMenu').title = '전체메뉴 닫힘';
|
document.querySelector('.btnAllMenu').title = '전체메뉴 닫힘';
|
||||||
document.querySelector('.all_menu.Mobile').classList.add('closed');
|
document.querySelector('.all_menu.Mobile').classList.add('closed');
|
||||||
} else {
|
} else {
|
||||||
alert(resp.resultMessage)
|
alert(resp.resultMessage)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const idFindModal = () => {
|
const idFindModal = useCallback(
|
||||||
setModalTitle("ID 찾기")
|
()=> {
|
||||||
setModalBody(IdFindForm)
|
setModalTitle("ID 찾기")
|
||||||
handleShow();
|
setModalBody(IdFindForm)
|
||||||
}
|
handleShow();
|
||||||
|
}
|
||||||
|
)
|
||||||
const pwFindModal = () => {
|
const pwFindModal = () => {
|
||||||
setModalTitle("PW 찾기")
|
setModalTitle("PW 찾기")
|
||||||
setModalBody(PwFindForm)
|
setModalBody(PwFindForm)
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,47 @@
|
||||||
|
|
||||||
|
import * as EgovNet from "../../api/egovFetch";
|
||||||
|
import CODE from "../../constants/code";
|
||||||
|
|
||||||
import Row from "react-bootstrap/Row";
|
import Row from "react-bootstrap/Row";
|
||||||
import Col from "react-bootstrap/Col";
|
import Col from "react-bootstrap/Col";
|
||||||
import Form from "react-bootstrap/Form";
|
import Form from "react-bootstrap/Form";
|
||||||
import Button from "react-bootstrap/Button";
|
import Button from "react-bootstrap/Button";
|
||||||
|
import {setLocalItem} from "../../utils/storage";
|
||||||
|
|
||||||
|
|
||||||
function IdFindForm(){
|
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 (
|
return (
|
||||||
<Form>
|
<Form onSubmit={findId} noValidate>
|
||||||
<Form.Group as={Row} className="mb-3" controlId="formHorizontalEmail">
|
<Form.Group as={Row} className="mb-3" controlId="formHorizontalEmail">
|
||||||
<Form.Label column sm={2}>
|
<Form.Label column sm={2}>
|
||||||
이메일
|
이메일
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={10}>
|
<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>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Form.Group as={Row} className="mb-3">
|
<Form.Group as={Row} className="mb-3">
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ function PwFindForm(){
|
||||||
아이디
|
아이디
|
||||||
</Form.Label>
|
</Form.Label>
|
||||||
<Col sm={10}>
|
<Col sm={10}>
|
||||||
<Form.Control type="email" placeholder="Email" />
|
<Form.Control type="text" placeholder="ID" />
|
||||||
</Col>
|
</Col>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Form.Group as={Row} className="mb-3" controlId="formHorizontalEmail">
|
<Form.Group as={Row} className="mb-3" controlId="formHorizontalEmail">
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,31 @@ public class EgovLoginApiController extends BaseController {
|
||||||
return resultMap;
|
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")
|
@RequestMapping("/accessTokenRefresh")
|
||||||
public HashMap<String, Object> accessTokenRefresh(HttpServletRequest request, HttpServletResponse response, @AuthenticationPrincipal UserInfo loginVO){
|
public HashMap<String, Object> accessTokenRefresh(HttpServletRequest request, HttpServletResponse response, @AuthenticationPrincipal UserInfo loginVO){
|
||||||
HashMap<String, Object> resultMap = new HashMap<>();
|
HashMap<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@ import java.util.Optional;
|
||||||
public interface UserInfoRepository extends JpaRepository<UserInfo, Integer> {
|
public interface UserInfoRepository extends JpaRepository<UserInfo, Integer> {
|
||||||
|
|
||||||
Optional<UserInfo> findByUserId(String userId);
|
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 boolean searchPassword(LoginVO vo) throws Exception;
|
||||||
|
|
||||||
public Integer insertUser(LoginVO loginVO);
|
public Integer insertUser(LoginVO loginVO);
|
||||||
|
|
||||||
|
String selectEmail(LoginVO loginVO);
|
||||||
}
|
}
|
||||||
|
|
@ -46,13 +46,25 @@ public class EgovLoginServiceImpl extends EgovAbstractServiceImpl implements Ego
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer insertUser(LoginVO loginVO){
|
public Integer insertUser(LoginVO loginVO){
|
||||||
UserInfo info = new UserInfo();
|
UserInfo savedUser = userInfoRepository.findByUserId(loginVO.getId()).orElse(null);
|
||||||
info.setUserId(loginVO.getId());
|
if(savedUser == null){
|
||||||
info.setPassword(convertPassword(loginVO.getPassword()));
|
savedUser = userInfoRepository.findByEmail(loginVO.getEmail()).orElse(null);
|
||||||
info.setEmail(loginVO.getEmail());
|
if (savedUser == null){
|
||||||
info.setUserSe("USR");
|
UserInfo info = new UserInfo();
|
||||||
userInfoRepository.save(info);
|
info.setUserId(loginVO.getId());
|
||||||
return info.getUserSeq();
|
info.setPassword(convertPassword(loginVO.getPassword()));
|
||||||
|
info.setEmail(loginVO.getEmail());
|
||||||
|
info.setUserSe("USR");
|
||||||
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,12 @@ public class SecurityConfig {
|
||||||
// 인증 예외 List
|
// 인증 예외 List
|
||||||
private String[] AUTH_WHITELIST = {
|
private String[] AUTH_WHITELIST = {
|
||||||
"/",
|
"/",
|
||||||
"/auth/login",
|
|
||||||
"/login",
|
"/login",
|
||||||
|
"/auth/login",
|
||||||
"/auth/accessTokenRefresh", // jwt accessToken 갱신
|
"/auth/accessTokenRefresh", // jwt accessToken 갱신
|
||||||
"/auth/join",//회원가입
|
"/auth/join",//회원가입
|
||||||
|
"/auth/findId", // id 찾기
|
||||||
|
"/auth/findPw", // pw 찾기
|
||||||
"/cmm/main/**.do", // 메인페이지
|
"/cmm/main/**.do", // 메인페이지
|
||||||
"/cmm/fms/FileDown.do", //파일 다운로드
|
"/cmm/fms/FileDown.do", //파일 다운로드
|
||||||
"/cmm/fms/getImage.do", //갤러리 이미지보기
|
"/cmm/fms/getImage.do", //갤러리 이미지보기
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue