Skip to content

Commit

Permalink
머지
Browse files Browse the repository at this point in the history
  • Loading branch information
parkrocket committed May 30, 2023
1 parent cf16edb commit a28e71c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />

<script type="text/javascript" src="https://static.nid.naver.com/js/naveridlogin_js_sdk_2.0.0.js"
charset="utf-8"></script>
<title>React App</title>
</head>
<body>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ import UserList from './admin/User/UserList';
import ConfigList from './admin/Config/ConfigList';
import MenuEdit from './admin/Config/MenuEdit'
import UserUpdate from './admin/User/UserUpdate';
import NaverLogin from '../pages/user/Social/NaverLogin'

export const Routes = () => {
return (
<ReactRouterRoutes>

<Route path="/" element={Auth(Main,null)} />
<Route path="/introduce" element={Auth(Introduce,true)} />
<Route path="/login" element={Auth(Login,false)} />
<Route path="/login" element={Auth(Login, false)} />
<Route path="/login/naver" element={Auth(NaverLogin,false)} />
<Route path="/register" element={Auth(Register,false)} />
<Route path="/mypage" element={Auth(Mypage,true)} />
<Route path="/board" element={Auth(BoardList,true)} />
Expand Down
9 changes: 7 additions & 2 deletions src/pages/board/BoardWrite.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ function Login(props) {
}

if (fileCount !== 0) {
for (let i = 0; i < event.target.upload_files.length; i++) {
formData.append("upload_files", event.target.upload_files[i].files[0]);
if (fileCount === 1) {
formData.append("upload_files", event.target.upload_files.files[0]);
} else {
for (let i = 0; i < event.target.upload_files.length; i++) {
formData.append("upload_files", event.target.upload_files[i].files[0]);
console.log(event.target.upload_files[i].files[0]);
}
}
}

Expand Down
19 changes: 18 additions & 1 deletion src/pages/user/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useCallback, useEffect } from "react";
import { useCookies } from "react-cookie";
import { useNavigate } from "react-router-dom";

Expand All @@ -8,6 +8,7 @@ import { loginUser } from "../../_actions/user_actions";
import Head from "../../components/Head";
import loginStyle from "../../Css/login.module.css";
import "../../Css/media.css";
const { naver } = window;

function Login(props) {
const [Id, setId] = useState("");
Expand All @@ -17,6 +18,20 @@ function Login(props) {
const navigate = useNavigate();
const dispatch = useDispatch();

const initializeNaverLogin = useCallback(() => {
const naverLogin = new naver.LoginWithNaverId({
clientId: "pT2rGH0Px2xILokqesF8",
callbackUrl: "http://localhost:3000/login/naver",
isPopup: false, // popup 형식으로 띄울것인지 설정
loginButton: { color: "white", type: 1, height: "47" }, //버튼의 스타일, 타입, 크기를 지정
});
naverLogin.init();
}, []);

useEffect(() => {
initializeNaverLogin();
}, [initializeNaverLogin]);

const onIdHandler = (event) => {
setId(event.currentTarget.value);
};
Expand All @@ -39,6 +54,7 @@ function Login(props) {
}
});
};

return (
<div>
<Head></Head>
Expand Down Expand Up @@ -70,6 +86,7 @@ function Login(props) {
<div className={`${loginStyle.log_section} ${loginStyle.log_lost}`}>
<a href="#!">아이디/비밀번호 찾기 </a>
</div>
<div id="naverIdLogin" />
<div>
<input
type="submit"
Expand Down
19 changes: 19 additions & 0 deletions src/pages/user/Social/NaverLogin.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import axios from "axios";
import { useLocation } from "react-router-dom";
import { useCookies } from "react-cookie";

function NaverLogin() {
const location = useLocation();

const token = location.hash.split("=")[1].split("&")[0];
const state = location.hash.split("=")[2].split("&")[0];

const [cookies, setCookie, removeCookie] = useCookies(["x_auth"]);

console.log(token, state, cookies);

return <div>naverlogin</div>;
}

export default NaverLogin;

0 comments on commit a28e71c

Please sign in to comment.