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

[FE] fix: 리뷰 작성 완료 페이지에 url로 직접 접근하는 행위 방지 #866

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

chysis
Copy link
Contributor

@chysis chysis commented Oct 16, 2024


🚀 어떤 기능을 구현했나요 ?

  • 리뷰 작성 완료 페이지에 url로 직접 접근하지 못하게 막았습니다.

🔥 어떻게 해결했나요 ?

  • 리뷰 작성 페이지에서 제출 버튼을 누를 때 navigate와 함께 state로 isValidAccess 플래그를 전달합니다. 리뷰 작성 완료 페이지에서는 state가 비어있거나, isValidAccess가 false일 때 홈페이지로 리다이렉션합니다.
  • PrivateRoute를 사용하는 방식도 있지만(https://velog.io/@somda/React-PrivateRoute-%EB%A7%8C%EB%93%A4%EA%B8%B0react-router-dom-v6), 이는 인증되지 않은 경우에 url 접근을 막는 것이라 다른 상황이라 판단했습니다.

📝 어떤 부분에 집중해서 리뷰해야 할까요?

📚 참고 자료, 할 말

Copy link
Contributor

@ImxYJL ImxYJL left a comment

Choose a reason for hiding this comment

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

앞으로 리뷰미의 볼륨이 늘어난다 해도 프리하게 접근할 수 있는 작성 페이지 쪽보다는 쿠키 검증을 거치는 리뷰 확인 쪽이 아닐까 싶어요.

작성 관련 페이지들이 늘어난다면 이렇게 접근 경로 체크할 일이 늘어날 수도 있으니 별도의 라우팅 관리 로직을 분리해서 관리하는 게 좋겠지만, 그렇지 않을 것 같아욥

그래서 에프이 구현대로 작성 페이지-작성 완료 페이지에서
간단하게 체크하고 넘어가는 것으로 충분할 것 같습니다~~

Copy link
Contributor

@BadaHertz52 BadaHertz52 left a comment

Choose a reason for hiding this comment

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

홈으로 리다이렉션되는 것에 대한 ux 우려가 있어요. 해당 코멘트 확인 부탁드려요

@@ -8,6 +9,13 @@ import * as S from './styles';

const ReviewWritingCompletePage = () => {
const navigate = useNavigate();
const location = useLocation();

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

제가 유저라면 url로 리뷰 완료 페이지 들어왔을때, 아무런 설명없이 바로 홈으로 리다이렉션이 되면 당황스러울 것 같아요.

저희가 ux를 생각해 오류가 나도 유저가 오류를 스스로 대응할 수 있는 선택권(홈,새로고침버튼)을 주었듯이, 유효하지 않은 리뷰 작성 완료 페이지에 접근하면 해당 접근이 유효하지 않다는 문구와 함께 홈으로 가는 이동 버튼을 제공하면 어떨까 싶어요

@@ -21,7 +21,7 @@ const useSubmitAnswers = ({ closeSubmitConfirmModal }: UseSubmitAnswersProps) =>
const navigate = useNavigate();

const executeAfterMutateSuccess = () => {
navigate(`/${ROUTE.reviewWritingComplete}/${reviewRequestCode}`);
navigate(`/${ROUTE.reviewWritingComplete}/${reviewRequestCode}`, { state: { isValidAccess: true } });
Copy link
Contributor

@BadaHertz52 BadaHertz52 Oct 17, 2024

Choose a reason for hiding this comment

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

리뷰 작성 -> 리뷰 작성 완료 -> 리뷰 작성 시에 다시 리뷰 작성 완료 페이지로 문제 없이 갈 수 있는데, 이 부분이 의도된 것인지 궁금해요

_2024_10_17_10_57_15_141.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

홈으로 돌아가기 버튼을 누른 경우에는 뒤로가기가 막혀 있는데, 위 영상처럼 이동할 때는 인지하지 못하고 있었네요. 수정해보겠습니다 :)

@chysis
Copy link
Contributor Author

chysis commented Oct 19, 2024

수정사항

1. Breadcrumb 수정

  • 현재는 number 타입의 path를 쓰지 않고 있어서 타입을 수정했습니다.
  • location을 사용해서, 현재 페이지가 리뷰 작성 완료 페이지라면 뒤로가기로 돌아갈 수 없게 수정했습니다.

리뷰 작성 완료 페이지

  • 유효한 접근인 경우: 리뷰 작성 폼 제출 버튼 클릭 시
  • 유효한 접근이 아닌 경우, ErrorSection을 보여주어 사용자가 새로고침 또는 홈으로 이동할 수 있게 수정했습니다.

url 직접 접근 막기.webm
▲ 살짝 화질구지입니다..

여러 상황을 가정하고 테스트 해보았지만 혹시나 추가적인 버그 발견 시 제보 부탁합니다

export interface Path {
pageName: string;
path: PathType;
path: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

순수 궁금증) 왜 기존 Path 타입에 number도 있었을까요? 지나치면서 궁금했었는데 이제야 질문을...ㅎ

Copy link
Contributor Author

Choose a reason for hiding this comment

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

breadcrumb 리팩토링 이전에는 navigate(0), navigate(-1)도 함께 사용되었어요 :0

return (
<ErrorSection
errorMessage="유효하지 않은 접근이에요"
handleReload={() => navigate(0)}
Copy link
Contributor

Choose a reason for hiding this comment

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

유효하지 않은 접근에 새로고침이 필요할까? 싶은 생각이 들었어요. 어차피 유효하지 않은 접근이었다면 아무리 새로고침해도 계속 똑같은 페이지를 보게 될 것이기 때문에...
다른 UI들을 살펴보니 바로 홈으로 리다이렉트시키지는 않지만, 선택지를 홈으로 돌아가기 하나만 주고 있었어요~


const handleNavigation = (path: PathType) => {
const handleNavigation = (path: string) => {
if (typeof path === 'number') {
Copy link
Contributor

Choose a reason for hiding this comment

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

path가 string 타입만 있다면 typeof path === 'number'는 필요없어지겠네요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

현재는 제거된 상태입니다

navigate(path);
}
const handleNavigation = (path: string) => {
navigate(path, { replace: location.pathname.includes(`/${ROUTE.reviewWritingComplete}`) });
Copy link
Contributor

@BadaHertz52 BadaHertz52 Oct 20, 2024

Choose a reason for hiding this comment

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

완료 페이지에서 뒤로가기를 막기 보다, 작성 -> 작성 완료 로 넘어갈 때 주는 state를 작성 완료 페이지 마운트 시useNavigate로 페이지 이동은 하지 않으면서 state:null로 바꾸는 것은 어떨까요? (pathname이 현재와 같으면 페이지 이동을 하지 않는다고 해요)

작성->작성 완료 -> 작성 에서 다시 이전 으로 돌아기로 작성 완료로 가도 유효하지 않은 접근이라는 것을 보여주고 새로 고침 시에도 유효하지 않은 접근으로 처리할 수 있을 것 같아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[FE] 리뷰 작성 완료 페이지에 url로 직접 접근하는 행위를 방지한다.
3 participants