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

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