33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { AxiosRequestConfig } from "axios";
|
|
import { BASE_URL } from "../constants";
|
|
import axiosInstance from "../http/axiosInstance";
|
|
import { IUser } from "../interfaces/user";
|
|
|
|
const config: AxiosRequestConfig = {
|
|
baseURL: BASE_URL.auth,
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
}
|
|
}
|
|
|
|
export default class AuthService {
|
|
static async login(data: URLSearchParams) {
|
|
return await axiosInstance.post(`/auth/login`, data, config)
|
|
}
|
|
|
|
static async refreshToken(token: string) {
|
|
return await axiosInstance.post(`/auth/refresh_token/${token}`, null, config)
|
|
}
|
|
|
|
static async getCurrentUser(token: string) {
|
|
return await axiosInstance.get(`/auth/get_current_user/${token}`, config)
|
|
}
|
|
|
|
static async resetPassword(email: string) {
|
|
return await axiosInstance.put(`/auth/user/reset_password?email=${email}`, null, config)
|
|
}
|
|
|
|
static async updatePassword(data: IUser) {
|
|
return await axiosInstance.put(`/auth/user/password_change`, data, config)
|
|
}
|
|
} |