diff --git a/package.json b/package.json index 35493034..1fbd13e9 100644 --- a/package.json +++ b/package.json @@ -58,5 +58,6 @@ "@types/react-csv": "^1.1.3", "@types/react-table": "^7.7.14", "@types/styled-components": "^5.1.26" - } + }, + "proxy": "http://146.56.98.74:3000" } diff --git a/src/pages/account/login/Login.tsx b/src/pages/account/login/Login.tsx index 1e78ae8e..3b2f5437 100644 --- a/src/pages/account/login/Login.tsx +++ b/src/pages/account/login/Login.tsx @@ -8,87 +8,39 @@ import axios from "axios"; const Login = () => { const [id, setId] = useState(""); const [password, setPassword] = useState(""); - const [samlResponse, setSamlResponse] = useState(""); - const [account, setAccount] = useRecoilState(accountAtom); - const navigate = useNavigate(); + const [studentId, setStudentId] = useState(""); - async function loginPost(id: string, password: string) { + const loginPost = async (id: string, password: string, studentId: string) => { const response = await axios.post( - "/sso/processAuthnResponse.do", + "/login", { - autoLogin: "Y", - SAMLRequest: - "3A65828FF982B8FF0105D06ED6791B72782655586BFE69341E49E861FDB70B1C0652AD672B8419D0E855F11C1DE485DB0B778FB784B60D31BB212970AF0786B8D693543DB7790BB8C77C6D3EA1D3CDCAF71E19C00251B0540F5F0EB66D41F13E4A7E5666097E5183FFADE84A1898659AB7BC874C63594E5C75DCF47B32E92A6744F31B6536C4DDD532C84635A7405F6F93DB005B8BF320257ECE49AC8CCA34C463BDD8E66990A97C95898931310C6841037538D0607333C41F01FB8880223EE637ED54AD713CEBB163E302386CF48EE151200953A7AA1C5676E5A7ED6A1937F0B0A873E124D1930B812E6649FE9DD9E9FF8C1BFE78EE9B751DE0FFE37D95905D14A92297E301F5BE299E3B019A74747020F0D5C57837A80CA877130F656F786E", - RelayState: null, - returnPage: "/jsp/sso/ip/login_form.jsp", - userAgent: "PC|MACINTEL|CHROME|114", - relogin: "N", - userId: id, + id: id, password: password, - token: null, - mobileAgentType: null, - userAgentIp: null, + studentNumber: studentId, }, { headers: { - "Content-Type": "application/x-www-form-urlencoded", - Accept: - "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7", - Referer: "https://sso.ajou.ac.kr/jsp/sso/ip/login_form.jsp", - Origin: "https://sso.ajou.ac.kr", - Host: "sso.ajou.ac.kr", - "User-Agent": - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36", + "Content-Type": "application/json", }, } ); - console.log(response.data); - // console.log(typeof response.data); - // DOMParser를 사용하여 HTML을 파싱 - const parser = new DOMParser(); - const doc = parser.parseFromString(response.data, "text/html"); - const targetElement = doc.querySelector("input[name=SAMLResponse]"); - if (targetElement) { - const targetAttribute = targetElement.getAttribute("value"); - if (targetAttribute) { - setSamlResponse(targetAttribute); - } - } - - loginSuccess(); - } - - async function loginSuccess() { - const response = await axios.post( - "/auth/ssoLoginSuccess.do", - { - domainName: "exciform.com", - SAMLResponse: samlResponse, - RelayState: null, - returnPage: "https://mportal.ajou.ac.kr", - }, - { - headers: { - "Content-Type": "application/x-www-form-urlencoded", - Accept: - "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7", - }, - withCredentials: true, - } - ); + // const response = await fetch("/login",{ + // method:"POST", + // headers:{ + // 'Content-Type': "application/json" + // }, + // }) console.log(response); - } + }; const onSumbit = (e: React.FormEvent) => { e.preventDefault(); - console.log(e); - loginPost(id, password); + console.log(id, password, studentId); + loginPost(id, password, studentId); }; - console.log(samlResponse); - console.log(document.cookie); return ( @@ -113,6 +65,16 @@ const Login = () => { onChange={(e) => setPassword(e.target.value)} /> + + 학번 + setStudentId(e.target.value)} + /> + 로그인 diff --git a/src/setupProxy.js b/src/setupProxy.js deleted file mode 100644 index c66be738..00000000 --- a/src/setupProxy.js +++ /dev/null @@ -1,23 +0,0 @@ -const { createProxyMiddleware } = require("http-proxy-middleware"); - -module.exports = function (app) { - app.use( - "/api", - createProxyMiddleware({ - target: "http://localhost:5000", - changeOrigin: true, - }) - ); - app.use( - createProxyMiddleware("/auth", { - target: "https://mhaksa.ajou.ac.kr:30443", - changeOrigin: true, - }) - ); - app.use( - createProxyMiddleware("/sso", { - target: "https://sso.ajou.ac.kr", - changeOrigin: true, - }) - ); -};