preparing svelte login, mastered translations

This commit is contained in:
2025-06-28 00:23:37 +02:00
parent f81fa50f27
commit 71cf6ec96d
17 changed files with 151 additions and 38 deletions

View File

@@ -0,0 +1,20 @@
export const user = $state({
name : null
})
export async function tryLogin(credentials){
var url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/login`;
let response = await fetch(url,{
headers: {
'Content-Type':'application/json'
},
method: 'POST',
body: JSON.stringify(credentials)
});
if (response.ok){
const json = await response.json();
for (var key of Object.keys(json)) user[key] = json[key];
} else {
alert("Login failed!");
}
}