auth.ts
728 Bytes
import axios from "axios";
import { AuthorizedState } from "@/store/modules/authorized/type";
import FileSaver from "file-saver";
export default class useAuthApi {
static async info() {
return axios
.get<{
user: AuthorizedState;
permissions: string[];
menus: string[];
can_create_demo: number
}>("auth/info")
.then((res) => Promise.resolve(res.data));
}
static changePwd(data: { password: string; password_confirmation: string }) {
return axios.put("auth/change-pwd", data);
}
static async downloadFile(url: string, fileName: string) {
// ?response-content-type=Blob
FileSaver.saveAs(`${url}`, fileName + url.substring(url.lastIndexOf(".")));
}
}