update: new start.py syntax and commands, fix: frontend not url encoded properly (could create problems with some passwords)

This commit is contained in:
Domingo Dirutigliano
2024-04-21 16:05:06 +02:00
parent 3e18e64d66
commit 9233b759df
3 changed files with 152 additions and 95 deletions

View File

@@ -85,7 +85,7 @@ export async function postapi(path:string,data:any,is_form:boolean=false):Promis
'Content-Type': is_form ? 'application/x-www-form-urlencoded' : 'application/json',
"Authorization" : "Bearer " + window.localStorage.getItem("access_token")
},
body: is_form ? data : JSON.stringify(data)
body: is_form ? (new URLSearchParams(data)).toString() : JSON.stringify(data)
}).then(res => {
if(res.status === 401) window.location.reload()
if(res.status === 406) resolve({status:"Wrong Password"})
@@ -157,7 +157,7 @@ export async function changepassword(data:ChangePassword) {
}
export async function login(data:PasswordSend) {
const from = "username=login&password=" + encodeURI(data.password);
const from = {username: "login", password: data.password};
const { status, access_token } = await postapi("login",from,true) as LoginResponse;
window.localStorage.setItem("access_token", access_token);
return status;