fix: revert fetchURL changes in auth (Fixes #2729) (#2739)

This commit is contained in:
kloon15 2023-10-01 18:09:13 +02:00 committed by GitHub
parent 01f7842a18
commit bd3c1941ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 22 deletions

View File

@ -1,7 +1,7 @@
import store from "@/store";
import router from "@/router";
import { Base64 } from "js-base64";
import { fetchURL } from "@/api/utils";
import { baseURL } from "@/utils/constants";
export function parseToken(token) {
const parts = token.split(".");
@ -32,17 +32,13 @@ export async function validateLogin() {
export async function login(username, password, recaptcha) {
const data = { username, password, recaptcha };
const res = await fetchURL(
`/api/login`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
const res = await fetch(`${baseURL}/api/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
false
);
body: JSON.stringify(data),
});
const body = await res.text();
@ -54,7 +50,7 @@ export async function login(username, password, recaptcha) {
}
export async function renew(jwt) {
const res = await fetchURL(`/api/renew`, {
const res = await fetch(`${baseURL}/api/renew`, {
method: "POST",
headers: {
"X-Auth": jwt,
@ -73,17 +69,13 @@ export async function renew(jwt) {
export async function signup(username, password) {
const data = { username, password };
const res = await fetchURL(
`/api/signup`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
const res = await fetch(`${baseURL}/api/signup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
false
);
body: JSON.stringify(data),
});
if (res.status !== 200) {
throw new Error(res.status);