This commit is contained in:
2024-01-11 17:34:44 +01:00
55 changed files with 44767 additions and 93 deletions

View File

@ -37,8 +37,8 @@ class Client
async isAuthentificate()
{
if (this._logged == undefined)
this.logged = await this._test_logged();
return this.logged;
this._logged = await this._test_logged();
return this._logged;
}
async _get(uri, data)
@ -103,31 +103,40 @@ class Client
async _update_logged(state)
{
if (this.logged == state)
if (this._logged == state)
return;
if (state)
{
this.me = new MyProfile(this);
await this.me.init();
[...document.getElementById('nav-account-links').children].forEach(el => {
if (el.matches('[logged-in]'))
el.classList.remove('d-none');
else
el.classList.add('d-none');
});
}
else
{
this.me = undefined;
[...document.getElementById('nav-account-links').children].forEach(el => {
if (el.matches('[logged-in]'))
el.classList.add('d-none');
else
el.classList.remove('d-none');
});
}
this.logged = state;
this._logged = state;
}
async login(username, password)
{
let response = await this._post("/api/accounts/login", {username: username, password: password})
if (response.status != 200)
return response.status;
if (response.status == 200)
await this._update_logged(true);
this._update_logged(true);
return 0;
return response;
}
async logout()