Skip to content

Commit

Permalink
#14 암호화 성공한건가 확인 부탁드립니다
Browse files Browse the repository at this point in the history
  • Loading branch information
bbmini96 committed Jun 23, 2024
1 parent 8acdf39 commit 8b626c0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
12 changes: 7 additions & 5 deletions src/api/FectUser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import axios from 'axios';

export async function fetchUserLogin(checkEmail, checkPassword) {
const response = await axios.post(`/api/login`, { email: checkEmail, password: checkPassword });
const data = await response.data;
return data;
}
// export async function fetchUserLogin(checkEmail, checkPassword) {
// const response = await axios.post(`/api/login`, { email: checkEmail, password: checkPassword});
// const data = await response.data;
// console.log(data)
// console.log(response)
// return data;
// }

export async function fetchUserSingup(checkName, checkEmail, checkPassword) {
const response = await axios.post(`/api/sign-up`, { name: checkName, email: checkEmail, password: checkPassword });
Expand Down
2 changes: 0 additions & 2 deletions src/components/Headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ export default function SearchAppBar() {
fetchLogout().then(() => {

setUserCookie(null);


// 쿠키 삭제
deleteCookie('email');
deleteCookie('name');
Expand Down
43 changes: 29 additions & 14 deletions src/pages/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,36 @@ export default function SingInPage({ data }) {
};


const handleSubmit = async(event) => {
event.preventDefault();

const handleSubmit = async (event) => {
event.preventDefault();
console.log(userLogin.email);
try {
const response = await axios.post('/api/login', userLogin);
// setCookie('name', response.name, { path: '/' });
// setCookie('email', response.email, { path: '/' });
// setCookie('id', response.id, { path: '/' });
navigate('/');

} catch (error) {
alert('아이디 또는 패스워드가 맞지 않습니다');
}




fetchUserLogin(userLogin.email, userLogin.password, userLogin.id)
.then((response) => {
// const encryptedId = encrypt(response.id);
// 쿠키 설정
setCookie('name', encodeURIComponent(response.name));
setCookie('email', response.email);
setCookie('id', response.id)
navigate(`/`);
})
.catch(error => {
alert("아이디 또는 패스워드가 맞지 않습니다");
});
// fetchUserLogin(userLogin.email, userLogin.password, userLogin.id)
// .then((response) => {
// // const encryptedId = encrypt(response.id);
// // 쿠키 설정
// setCookie('name', encodeURIComponent(response.name));
// setCookie('email', response.email);
// setCookie('id', response.id)
// navigate(`/`);
// })
// .catch(error => {
// alert("아이디 또는 패스워드가 맞지 않습니다");
// });
};

// const encrypt = (value) => {
Expand Down

0 comments on commit 8b626c0

Please sign in to comment.