[skip ci] add field verify code (MFA) for login
This commit is contained in:
@ -28,7 +28,7 @@ interface AuthContextProps {
|
||||
saveAuth: (auth: AuthModel | undefined) => void;
|
||||
currentUser: UserModel | undefined;
|
||||
setCurrentUser: Dispatch<SetStateAction<UserModel | undefined>>;
|
||||
login: (email: string, password: string) => Promise<void>;
|
||||
login: (email: string, password: string, token?: string) => Promise<void>;
|
||||
requestPasswordResetLink: (email: string) => Promise<void>;
|
||||
changePassword: (token: string, password: string, password_confirmation: string) => Promise<void>;
|
||||
getUser: () => Promise<AxiosResponse<any> | {}>;
|
||||
@ -52,10 +52,10 @@ const AuthProvider = ({ children }: PropsWithChildren) => {
|
||||
}
|
||||
};
|
||||
|
||||
const login = async (username: string, password: string) => {
|
||||
const login = async (username: string, password: string, token?: string) => {
|
||||
try {
|
||||
const { data: auth } = await axios
|
||||
.post(LOGIN_URL, { username, password })
|
||||
.post(LOGIN_URL, { username, password, token })
|
||||
.then((response) => response.data);
|
||||
|
||||
const enhancedAuth: AuthModel = {
|
||||
@ -63,7 +63,7 @@ const AuthProvider = ({ children }: PropsWithChildren) => {
|
||||
id: auth.user.id,
|
||||
role_name: auth.role_name,
|
||||
user: auth.user,
|
||||
statusbalance: auth.role?.status_balance ?? null // SAFE ACCESS
|
||||
statusbalance: auth.role?.status_balance ?? null // SAFE ACCESS
|
||||
};
|
||||
|
||||
saveAuth(enhancedAuth);
|
||||
@ -161,4 +161,4 @@ const AuthProvider = ({ children }: PropsWithChildren) => {
|
||||
);
|
||||
};
|
||||
|
||||
export { AuthContext, AuthProvider };
|
||||
export { AuthContext, AuthProvider };
|
||||
|
||||
Reference in New Issue
Block a user