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

[비즈니스] 비밀번호 찾기 문자인증 도입 #349

Merged
merged 18 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import OwnerLayout from 'layout/OwnerLayout';
import CoopLayout from 'layout/CoopLayout';
import Login from 'page/Auth/Login';
import Signup from 'page/Auth/Signup';
import FindPassword from 'page/Auth/FindPassword/SendAuthNumber';
import NewPassword from 'page/Auth/FindPassword/NewPassword';
import CompleteChangePassword from 'page/Auth/FindPassword/CompleteChangePassword';
import AuthLayout from 'layout/AuthLayout';
import MyShopPage from 'page/MyShopPage';
import ShopRegistration from 'page/ShopRegistration';
Expand All @@ -23,6 +20,7 @@ import AddingEvent from 'page/ManageEvent/AddingEvent';
import ModifyEvent from 'page/ManageEvent/ModifyEvent';
import LogPage from 'component/common/PageLog';
import CommonLayout from 'page/Auth/components/Common';
import FindPassword from 'page/Auth/FindPassword';

interface ProtectedRouteProps {
userTypeRequired: UserType;
Expand Down Expand Up @@ -80,11 +78,7 @@ function App() {
<Route path="/find-id" element={<PageNotFound />} />
<Route path="/find-password" element={<FindPassword />} />
</Route>
<Route path="/find" element={<CommonLayout />} />
<Route path="/register" element={<CommonLayout />} />
</Route>
<Route path="/new-password" element={<NewPassword />} />
<Route path="/complete-change-password" element={<CompleteChangePassword />} />
</Route>
</Routes>
<Toast />
Expand Down
14 changes: 14 additions & 0 deletions src/api/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { accessClient, client } from 'api';
import {
CertificationResponse,
LoginParams, LoginResponse, OwnerResponse, UserTypeResponse,
} from 'model/auth';

Expand Down Expand Up @@ -34,3 +35,16 @@ export const findPassword = ({
});

export const newPassword = ({ address, password }: { address: string, password: string }) => client.put('/owners/password/reset', { address, password });

export const sendVerifyCode = (phone_number: string) => client.post('/owners/password/reset/verification/sms', {
phone_number,
});

export const verifyCode = ({ phone_number, certification_code } : { phone_number:string, certification_code:string }) => client.post<CertificationResponse>('/owners/password/reset/send/sms', {
phone_number, certification_code,
});

export const changePassword = ({ phone_number, password } : { phone_number:string, password:string }) => client.put('/owners/password/reset/sms', {
phone_number,
password,
});
26 changes: 26 additions & 0 deletions src/model/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,29 @@ export type User = z.infer<typeof User>;
export interface LoginForm extends LoginParams {
isAutoLogin: boolean;
}

export interface CertificationResponse {
token: string;
}

export interface ChangePasswordForm {
password: string;
passwordCheck: string;
phone_number: string;
}

interface FindPassword {
phone_number: string;
certification_code: string;
password: string;
}

export interface Register extends FindPassword {
company_number: string,
name: string,
shop_id: number,
shop_name: string,
attachment_urls: {
file_url: string
}[],
}
83 changes: 83 additions & 0 deletions src/page/Auth/FindPassword/ChangePassword/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { useEffect } from 'react';
import { useFormContext } from 'react-hook-form';
import { useOutletContext } from 'react-router-dom';
import { ChangePasswordForm } from 'model/auth';
import { OutletProps } from 'page/Auth/FindPassword/entity';
import { ReactComponent as Warning } from 'assets/svg/auth/warning.svg';
import styles from 'page/Auth/FindPassword/index.module.scss';

const passwordRegex = /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{6,18}$/;

export default function ChangePassword() {
const {
register, formState: { errors, isValid }, getValues, clearErrors,
} = useFormContext<ChangePasswordForm>();

const steps: OutletProps = useOutletContext();
const { setIsStepComplete } = steps;

useEffect(() => {
if (isValid) {
clearErrors();
setIsStepComplete(true);
} else {
setIsStepComplete(false);
}
});

return (
<form className={styles.container}>
<section className={styles.section}>
<div className={styles.title}>새 비밀번호</div>
<input
className={styles.input}
type="password"
placeholder="새 비밀번호를 입력해주세요."
{...register('password', {
required: {
value: true,
message: '필수 입력 항목입니다.',
},
pattern: {
value: passwordRegex,
message: '특수문자 포함 영어와 숫자 6~18 자리로 입력해주세요.',
},
})}
/>
{
errors.password
? (
<div className={styles.error}>
<Warning />
{errors.password.message}
</div>
) : (
<div className={styles.comment}>
* 특수문자 포함 영어와 숫자 6~18 자리
</div>
)
}

</section>
<section className={styles.section}>
<div className={styles.title}>새 비밀번호 확인</div>
<input
className={styles.input}
type="password"
placeholder="새 비밀번호를 다시 입력해주세요."
{...register('passwordCheck', {
validate: (value) => value === getValues('password') || '비밀번호가 일치하지 않습니다.',
})}
/>
{
errors.passwordCheck && (
<div className={styles.error}>
<Warning />
{errors.passwordCheck.message}
</div>
)
}
</section>
</form>
);
}

This file was deleted.

32 changes: 0 additions & 32 deletions src/page/Auth/FindPassword/CompleteChangePassword/index.tsx

This file was deleted.

107 changes: 0 additions & 107 deletions src/page/Auth/FindPassword/NewPassword/NewPassword.module.scss

This file was deleted.

Loading
Loading