This commit is contained in:
fro1991
2025-02-01 19:49:27 +07:00
parent 42c2a8e481
commit 13a2c4d42c
57 changed files with 159 additions and 295 deletions

View File

@ -14,7 +14,7 @@ import { type AuthModel, type UserModel } from '@/auth';
import { apiConfig } from '@/config/api.config';
import { doSaveLogActivity } from '@/actions/GlobalActions';
const API_URL = apiConfig.service_user;
const API_URL = apiConfig.service_dashboard;
export const LOGIN_URL = `${API_URL}/login`;
export const FORGOT_PASSWORD_URL = `${API_URL}/reset_password`;
@ -28,7 +28,7 @@ interface AuthContextProps {
saveAuth: (auth: AuthModel | undefined) => void;
currentUser: UserModel | undefined;
setCurrentUser: Dispatch<SetStateAction<UserModel | undefined>>;
login: (email: string, password: string, application: string) => Promise<void>;
login: (email: string, password: string) => Promise<void>;
requestPasswordResetLink: (email: string) => Promise<void>;
changePassword: (token: string, password: string, password_confirmation: string) => Promise<void>;
getUser: () => Promise<AxiosResponse<any> | {}>;
@ -70,13 +70,12 @@ const AuthProvider = ({ children }: PropsWithChildren) => {
}
};
const login = async (username: string, password: string, application: string) => {
const login = async (username: string, password: string) => {
try {
const { data: auth } = await axios
.post(LOGIN_URL, { username, password, application })
.post(LOGIN_URL, { username, password })
.then((response) => response.data);
// console.log('auth :', auth);
saveAuth({ ...auth.token, id: auth.user.id, role_name: auth.role_name, user: auth.user });
setCurrentUser(auth.user);
const createActivity = {