fixed login bug

This commit is contained in:
MathMan05 2024-08-19 11:32:21 -05:00
parent 1506521835
commit ec2fc491d9
2 changed files with 8 additions and 2 deletions

View file

@ -237,7 +237,7 @@ async function login(username, password, captcha) {
try {
const info = JSON.parse(localStorage.getItem("instanceinfo"));
const api = info.login + (info.login.startsWith("/") ? "/" : "");
return await fetch(api + 'auth/login', options).then(response => response.json())
return await fetch(api + '/auth/login', options).then(response => response.json())
.then((response) => {
console.log(response, response.message);
if ("Invalid Form Body" === response.message) {
@ -282,6 +282,8 @@ async function login(username, password, captcha) {
}
else {
console.warn(response);
if (!response.token)
return;
adduser({ serverurls: JSON.parse(localStorage.getItem("instanceinfo")), email: username, token: response.token }).username = username;
const redir = new URLSearchParams(window.location.search).get("goback");
if (redir) {
@ -296,6 +298,8 @@ async function login(username, password, captcha) {
}
else {
console.warn(response);
if (!response.token)
return;
adduser({ serverurls: JSON.parse(localStorage.getItem("instanceinfo")), email: username, token: response.token }).username = username;
const redir = new URLSearchParams(window.location.search).get("goback");
if (redir) {

View file

@ -233,7 +233,7 @@ async function login(username:string, password:string, captcha:string){
try{
const info=JSON.parse(localStorage.getItem("instanceinfo"));
const api=info.login+(info.login.startsWith("/")?"/":"");
return await fetch(api+'auth/login',options).then(response=>response.json())
return await fetch(api+'/auth/login',options).then(response=>response.json())
.then((response) => {
console.log(response,response.message)
if("Invalid Form Body"===response.message){
@ -278,6 +278,7 @@ async function login(username:string, password:string, captcha:string){
alert(response.message)
}else{
console.warn(response);
if(!response.token) return;
adduser({serverurls:JSON.parse(localStorage.getItem("instanceinfo")),email:username,token:response.token}).username=username;
const redir=new URLSearchParams(window.location.search).get("goback");
if(redir){
@ -290,6 +291,7 @@ async function login(username:string, password:string, captcha:string){
}]]).show();
}else{
console.warn(response);
if(!response.token) return;
adduser({serverurls:JSON.parse(localStorage.getItem("instanceinfo")),email:username,token:response.token}).username=username;
const redir=new URLSearchParams(window.location.search).get("goback");
if(redir){