diff --git a/src/mocks/mockData.ts b/src/mocks/mockData.ts index 0ae35704..4b472cb0 100644 --- a/src/mocks/mockData.ts +++ b/src/mocks/mockData.ts @@ -34,7 +34,7 @@ type TaskFile = { export const JWT_TOKEN_DUMMY = 'mocked-header.mocked-payload-4.mocked-signature'; -export const emailVerificationCode = '1234'; +export const VERIFICATION_CODE_DUMMY = '1234'; export const USER_INFO_DUMMY = { provider: 'LOCAL', diff --git a/src/mocks/services/authServiceHandler.ts b/src/mocks/services/authServiceHandler.ts index 770953f4..f6c61d77 100644 --- a/src/mocks/services/authServiceHandler.ts +++ b/src/mocks/services/authServiceHandler.ts @@ -1,7 +1,7 @@ import Cookies from 'js-cookie'; import { http, HttpResponse } from 'msw'; import { AUTH_SETTINGS } from '@constants/settings'; -import { emailVerificationCode, USER_INFO_DUMMY } from '@mocks/mockData'; +import { VERIFICATION_CODE_DUMMY, USER_INFO_DUMMY } from '@mocks/mockData'; import { EmailVerificationForm, RequestEmailCode, @@ -130,9 +130,9 @@ const authServiceHandler = [ // 이메일 인증 번호 확인 API http.post(`${BASE_URL}/user/verify/code`, async ({ request }) => { - const { email, code } = (await request.json()) as EmailVerificationForm; + const { email, verificationCode } = (await request.json()) as EmailVerificationForm; - if (email !== USER_INFO_DUMMY.email || code !== emailVerificationCode) + if (email !== USER_INFO_DUMMY.email || verificationCode !== VERIFICATION_CODE_DUMMY) return HttpResponse.json({ message: '인증번호가 일치하지 않습니다.' }, { status: 401 }); return HttpResponse.json(null, { status: 200 }); @@ -140,9 +140,9 @@ const authServiceHandler = [ // 아이디 찾기 API http.post(`${BASE_URL}/user/recover/username`, async ({ request }) => { - const { email, code } = (await request.json()) as EmailVerificationForm; + const { email, verificationCode } = (await request.json()) as EmailVerificationForm; - if (code !== emailVerificationCode) { + if (verificationCode !== VERIFICATION_CODE_DUMMY) { return HttpResponse.json( { message: '이메일 인증 번호가 일치하지 않습니다. 다시 확인해 주세요.' }, { status: 401 }, @@ -157,11 +157,11 @@ const authServiceHandler = [ // 비밀번호 찾기 API http.post(`${BASE_URL}/user/recover/password`, async ({ request }) => { - const { username, email, code } = (await request.json()) as SearchPasswordForm; + const { username, email, verificationCode } = (await request.json()) as SearchPasswordForm; const tempPassword = '!1p2l3nqlz'; - if (code !== emailVerificationCode) { + if (verificationCode !== VERIFICATION_CODE_DUMMY) { return HttpResponse.json( { message: '이메일 인증 번호가 일치하지 않습니다. 다시 확인해 주세요.' }, { status: 401 }, diff --git a/src/pages/setting/UserAuthenticatePage.tsx b/src/pages/setting/UserAuthenticatePage.tsx index c44b825b..ae1603aa 100644 --- a/src/pages/setting/UserAuthenticatePage.tsx +++ b/src/pages/setting/UserAuthenticatePage.tsx @@ -59,8 +59,8 @@ function UserAuthenticatePage() { {isVerificationRequested && ( )} diff --git a/src/pages/user/SearchIdPage.tsx b/src/pages/user/SearchIdPage.tsx index 4caa9c6d..5507b300 100644 --- a/src/pages/user/SearchIdPage.tsx +++ b/src/pages/user/SearchIdPage.tsx @@ -20,7 +20,7 @@ export default function SearchIdPage() { mode: 'onChange', defaultValues: { email: '', - code: '', + verificationCode: '', }, }); const { handleSubmit, setError, setValue } = methods; @@ -33,11 +33,11 @@ export default function SearchIdPage() { // ToDo: useAxios 훅 적용 후 해당 함수 수정 및 삭제하기 const handleVerificationError = () => { - setError('code', { + setError('verificationCode', { type: 'manual', message: '인증번호가 일치하지 않습니다.', }); - setValue('code', ''); + setValue('verificationCode', ''); }; // ToDo: useAxios 훅을 이용한 네트워크 로직으로 변경 diff --git a/src/pages/user/SearchPasswordPage.tsx b/src/pages/user/SearchPasswordPage.tsx index 20f3676c..6cd75075 100644 --- a/src/pages/user/SearchPasswordPage.tsx +++ b/src/pages/user/SearchPasswordPage.tsx @@ -20,7 +20,7 @@ export default function SearchPasswordPage() { defaultValues: { username: '', email: '', - code: '', + verificationCode: '', }, }); const { handleSubmit, setError, setValue } = methods; @@ -33,11 +33,11 @@ export default function SearchPasswordPage() { // ToDo: useAxios 훅 적용 후 해당 함수 수정 및 삭제하기 const handleVerificationError = () => { - setError('code', { + setError('verificationCode', { type: 'manual', message: '인증번호가 일치하지 않습니다.', }); - setValue('code', ''); + setValue('verificationCode', ''); }; // ToDo: useAxios 훅을 이용한 네트워크 로직으로 변경 diff --git a/src/pages/user/SignUpPage.tsx b/src/pages/user/SignUpPage.tsx index 7384a4fb..4baa77b9 100644 --- a/src/pages/user/SignUpPage.tsx +++ b/src/pages/user/SignUpPage.tsx @@ -20,7 +20,7 @@ export default function SignUpPage() { defaultValues: { username: null, email: '', - code: '', + verificationCode: '', nickname: '', password: '', checkPassword: '', @@ -32,12 +32,12 @@ export default function SignUpPage() { // form 전송 함수 const onSubmit = async (data: UserSignUpForm) => { - const { username, code, checkPassword, profileImageName, ...filteredData } = data; + const { username, verificationCode, checkPassword, profileImageName, ...filteredData } = data; console.log(data); // TODO: 폼 제출 로직 수정 필요 try { // 회원가입 폼 - const formData = { ...filteredData, username, code, profileImageName }; + const formData = { ...filteredData, username, verificationCode, profileImageName }; const registrationResponse = await axios.post(`http://localhost:8080/api/v1/user/${username}`, formData); if (registrationResponse.status !== 200) return toastError('회원가입에 실패했습니다. 다시 시도해 주세요.'); @@ -93,8 +93,8 @@ export default function SignUpPage() { {isVerificationRequested && ( )} diff --git a/src/types/UserType.tsx b/src/types/UserType.tsx index 0fcf865f..0e37c705 100644 --- a/src/types/UserType.tsx +++ b/src/types/UserType.tsx @@ -17,7 +17,7 @@ export type UserWithRole = SearchUser & Pick; export type EditUserInfoForm = Omit; export type UserSignUpForm = Omit & { - code: string; + verificationCode: string; password: string; checkPassword: string; }; @@ -26,9 +26,9 @@ export type UserSignInForm = Pick & { password: string; }; -export type EmailVerificationForm = Pick & { code: string }; +export type EmailVerificationForm = Pick & { verificationCode: string }; -export type SearchPasswordForm = Pick & { code: string }; +export type SearchPasswordForm = Pick & { verificationCode: string }; export type UpdatePasswordForm = { password: string;