Compare commits

..

No commits in common. "943e759060a3bb32b2fbe678eb138ecc44316695" and "de9edc41ee9096a51e4b06512df91532884fea0d" have entirely different histories.

8 changed files with 32 additions and 113 deletions

View File

@ -85,3 +85,4 @@ button {cursor: pointer;}
.clickable{cursor: pointer;} .clickable{cursor: pointer;}
.findBtn{float: right}

View File

@ -7,9 +7,9 @@ import URL from 'constants/url';
import CODE from 'constants/code'; 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 Modal from "react-bootstrap/Modal";
import { getLocalItem, setLocalItem, setSessionItem } from 'utils/storage'; import { getLocalItem, setLocalItem, setSessionItem } from 'utils/storage';
import Modal from "react-bootstrap/Modal";
import IdFindForm from "./IdFindForm"; import IdFindForm from "./IdFindForm";
import PwFindForm from "./PwFindForm"; import PwFindForm from "./PwFindForm";

View File

@ -1,10 +1,12 @@
import * as EgovNet from "../../api/egovFetch"; 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(){
@ -26,7 +28,7 @@ function IdFindForm(){
body: JSON.stringify({email: form.email.value}) body: JSON.stringify({email: form.email.value})
}, },
(resp) => { (resp) => {
document.querySelector("#findResultLabel").innerText = resp.resultMessage; alert(resp.resultMessage)
}) })
} }
} }
@ -42,12 +44,11 @@ function IdFindForm(){
<Form.Control.Feedback type={"invalid"} >메일을 입력해주세요.</Form.Control.Feedback> <Form.Control.Feedback type={"invalid"} >메일을 입력해주세요.</Form.Control.Feedback>
</Col> </Col>
</Form.Group> </Form.Group>
<Row className="mb-3"> <Form.Group as={Row} className="mb-3">
<Form.Label column xs={{span:8, offset:2}} id="findResultLabel"></Form.Label> <Col sm={{ span: 10, offset: 2 }}>
<Col xs={2}> <Button className="findBtn" type="submit">찾기</Button>
<Button type="submit">찾기</Button>
</Col> </Col>
</Row> </Form.Group>
</Form> </Form>
); );
} }

View File

@ -2,42 +2,16 @@ import Form from "react-bootstrap/Form";
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 Button from "react-bootstrap/Button"; import Button from "react-bootstrap/Button";
import * as EgovNet from "../../api/egovFetch";
function PwFindForm(){ function PwFindForm(){
const findPw = (e) => {
e.preventDefault();
e.stopPropagation();
const form = e.currentTarget;
if(!form.email.value){
alert("이메일을 입력해주세요.")
}if(!form.id.value){
alert("아이디를 입력해주세요.")
}else{
EgovNet.requestFetch(
"/auth/findPw",
{
method: "POST",
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify({email: form.email.value, id: form.id.value})
},
(resp) => {
document.querySelector("#findResultLabel").innerText = resp.resultMessage;
})
}
}
return ( return (
<Form onSubmit={findPw} noValidate> <Form>
<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="text" name="id" placeholder="ID" required /> <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">
@ -45,15 +19,14 @@ function PwFindForm(){
이메일 이메일
</Form.Label> </Form.Label>
<Col sm={10}> <Col sm={10}>
<Form.Control type="email" name="email" placeholder="Email" required/> <Form.Control type="email" placeholder="Email" />
</Col> </Col>
</Form.Group> </Form.Group>
<Row className="mb-3"> <Form.Group as={Row} className="mb-3">
<Form.Label column xs={{span:8, offset:2}} id="findResultLabel"></Form.Label> <Col sm={{ span: 10, offset: 2 }}>
<Col xs={2}> <Button className="findBtn" type="submit">찾기</Button>
<Button type="submit">찾기</Button>
</Col> </Col>
</Row> </Form.Group>
</Form> </Form>
); );
} }

View File

@ -97,16 +97,8 @@ public class EgovLoginApiController extends BaseController {
Integer insertResult = loginService.insertUser(loginVO); Integer insertResult = loginService.insertUser(loginVO);
if(insertResult!=null){ if(insertResult!=null){
if(insertResult==-1){ resultMap.put("resultCode", ResponseCode.SUCCESS.getCode());
resultMap.put("resultCode", ResponseCode.SAVE_ERROR.getCode()); resultMap.put("resultMessage", "저장 되었습니다.");
resultMap.put("resultMessage", "사용중인 아이디입니다.");
}else if(insertResult==-2){
resultMap.put("resultCode", ResponseCode.SAVE_ERROR.getCode());
resultMap.put("resultMessage", "가입된 이메일입니다.");
}else{
resultMap.put("resultCode", ResponseCode.SUCCESS.getCode());
resultMap.put("resultMessage", "저장 되었습니다.");
}
}else{ }else{
resultMap.put("resultCode", ResponseCode.SAVE_ERROR.getCode()); resultMap.put("resultCode", ResponseCode.SAVE_ERROR.getCode());
resultMap.put("resultMessage", "저장에 실패하였습니다."); resultMap.put("resultMessage", "저장에 실패하였습니다.");
@ -140,30 +132,6 @@ 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 = "/findPw")
public HashMap<String, Object> findPw(@RequestBody LoginVO loginVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
String password = loginService.updateTempPassword(loginVO);
if(password!=null){
resultMap.put("resultCode", ResponseCode.SUCCESS.getCode());
resultMap.put("resultMessage", "비밀번호가 발급되었습니다.\n 새 비밀번호: "+password);
}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<>();

View File

@ -10,6 +10,4 @@ public interface UserInfoRepository extends JpaRepository<UserInfo, Integer> {
Optional<UserInfo> findByUserId(String userId); Optional<UserInfo> findByUserId(String userId);
Optional<UserInfo> findByEmail(String email); Optional<UserInfo> findByEmail(String email);
Optional<UserInfo> findByEmailAndUserId(String email, String id);
} }

View File

@ -2,7 +2,6 @@ package com.dbnt.kcscbackend.auth.service;
import com.dbnt.kcscbackend.auth.entity.LoginVO; import com.dbnt.kcscbackend.auth.entity.LoginVO;
import com.dbnt.kcscbackend.auth.entity.UserInfo;
/** /**
* *
@ -53,6 +52,4 @@ public interface EgovLoginService {
public Integer insertUser(LoginVO loginVO); public Integer insertUser(LoginVO loginVO);
String selectEmail(LoginVO loginVO); String selectEmail(LoginVO loginVO);
String updateTempPassword(LoginVO loginVO);
} }

View File

@ -17,8 +17,6 @@ import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Random;
/** /**
* *
* @author * @author
@ -48,21 +46,20 @@ public class EgovLoginServiceImpl extends EgovAbstractServiceImpl implements Ego
@Transactional @Transactional
public Integer insertUser(LoginVO loginVO){ public Integer insertUser(LoginVO loginVO){
UserInfo idCheck = userInfoRepository.findByUserId(loginVO.getId()).orElse(null); UserInfo savedUser = userInfoRepository.findByUserId(loginVO.getId()).orElse(null);
if (idCheck != null){ if(savedUser == null){
return -1; savedUser = userInfoRepository.findByEmail(loginVO.getEmail()).orElse(null);
if (savedUser == null){
UserInfo info = new UserInfo();
info.setUserId(loginVO.getId());
info.setPassword(convertPassword(loginVO.getPassword()));
info.setEmail(loginVO.getEmail());
info.setUserSe("USR");
userInfoRepository.save(info);
return info.getUserSeq();
}
} }
UserInfo emailCheck = userInfoRepository.findByEmail(loginVO.getEmail()).orElse(null); return null;
if(emailCheck != null){
return -2;
}
UserInfo info = new UserInfo();
info.setUserId(loginVO.getId());
info.setPassword(convertPassword(loginVO.getPassword()));
info.setEmail(loginVO.getEmail());
info.setUserSe("USR");
userInfoRepository.save(info);
return info.getUserSeq();
} }
public String selectEmail(LoginVO loginVO){ public String selectEmail(LoginVO loginVO){
@ -70,22 +67,6 @@ public class EgovLoginServiceImpl extends EgovAbstractServiceImpl implements Ego
return savedUser==null?null:savedUser.getUserId(); return savedUser==null?null:savedUser.getUserId();
} }
@Transactional
public String updateTempPassword(LoginVO loginVO){
UserInfo user = userInfoRepository.findByEmailAndUserId(loginVO.getEmail(), loginVO.getId()).orElse(null);
if(user!=null){
Random rd = new Random();
StringBuilder password = new StringBuilder();
for(int i=0; i<10; i++){
int rdNum = rd.nextInt(95)+33;
password.append((char)rdNum);
}
user.setPassword(convertPassword(password.toString()));
return password.toString();
}
return null;
}
@Override @Override
public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundException { public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundException {
return userInfoRepository.findByUserId(userId).orElseThrow(() -> new UsernameNotFoundException(userId)); return userInfoRepository.findByUserId(userId).orElseThrow(() -> new UsernameNotFoundException(userId));