Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clo-or] 프론트엔드 3주차 미션 제출합니다. #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

clo-or
Copy link

@clo-or clo-or commented Dec 19, 2024

No description provided.

Copy link
Collaborator

@hhhkdev hhhkdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3주차 미션 퀄리티가 좋네요 로그인과 토큰 쪽을 구현했다는게 의미가 있을듯합니다 프로젝트 트랙을 하면서 아무래도 로그인 기능이 들어갈 가능성이 높을텐데, 그때 여기서 발전시켜서 이용하면 좋을거 같아여

Comment on lines +9 to +20
useEffect(() => {
// localStorage에서 토큰 확인
const token = localStorage.getItem("authToken");
if (token === "mock-jwt-token-12345") {
setIsAuthenticated(true);
}
}, []);

const handleLogout = () => {
localStorage.removeItem("authToken"); // 로그아웃 시 토큰 삭제
setIsAuthenticated(false);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앞서 배운 토큰의 개념을 잘 활용하여 작성했다는 생각이 드네요!

Comment on lines +18 to +26
const user = USERS[userId];
if (user && user.password === password) {
setError("");
localStorage.setItem("authToken", user.token);
setAuth(true);
} else {
setError("Invalid username or password");
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그인에서 에러 처리도 확실하게 되었다는 생각이 드네요 다만 로그인에 성공했을 경우에 바로 페이지로 이동하게 해도 좋을거 같습니당

Comment on lines +3 to +7
const USERS = {
testUser: {
password: "password123",
token: "mock-jwt-token-12345",
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

목데이터를 만들어서 테스트하는게 좋긴하네요 추후에는 따로 파일을 분리해서 public 폴더에서 관리해봐도 좋을거 같습니당

const decrement = () => setCount(count - step);

return (
<div style={{ margin: '1rem', textAlign: 'center' }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔한 카운터네요 여기에 스타일을 바로 때려넣기보단 css 파일을 분리하거나 styled component 혹은 emotion에 대해 알아보면 좋을거 같습니당

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants