| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { get } from "../config/request";
- import axiosAPI from "../config/axios";
- import { createLog } from "./log";
- import { getCsrf } from "./security";
- export const login = async (username, password) => {
- const data = {
- username,
- password,
- };
- const response = await axiosAPI.post("/auth/login", data, {
- headers: {
- "Content-Type": "application/json",
- },
- });
- return response.data;
- };
- export const refreshToken = async () => {
- try {
- const response = await axiosAPI.get("/token");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const getUser = async () => {
- try {
- const response = await get("/user");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const logout = async ( _csrf) => {
- try {
- const response = await axiosAPI.delete(`/auth/logout?_csrf=${_csrf}`);
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const loginToPt = async (lembaga_id, password, _csrf) => {
- const data = {
- lembaga_id,
- password,
- };
- const response = await axiosAPI.post(`/auth/login-to-pt?_csrf=${_csrf}`, data, {
- headers: {
- "Content-Type": "application/json",
- },
- });
- return response.data;
- };
|