tentative de merge
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import { Account } from "./account.js";
|
||||
import { MatchMaking } from "./matchmaking.js";
|
||||
import { Profile } from "./profile.js";
|
||||
import { Profiles } from "./profiles.js";
|
||||
import { Channels } from './chat/channels.js';
|
||||
import { MyProfile } from "./MyProfile.js";
|
||||
|
||||
function getCookie(name)
|
||||
{
|
||||
@ -94,15 +94,23 @@ class Client
|
||||
return response;
|
||||
}
|
||||
|
||||
async _update_logged(state)
|
||||
{
|
||||
if (this.logged && state)
|
||||
{
|
||||
this.me = new MyProfile(this);
|
||||
await this.me.init();
|
||||
}
|
||||
this.logged = state;
|
||||
}
|
||||
|
||||
async login(username, password)
|
||||
{
|
||||
let response = await this._post("/api/accounts/login", {username: username, password: password})
|
||||
let data = await response.json();
|
||||
if (data.id != undefined)
|
||||
{
|
||||
this.me = new Profile(this)
|
||||
await this.me.init(data.id)
|
||||
this.logged = true;
|
||||
await this._update_logged(true);
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
@ -111,7 +119,7 @@ class Client
|
||||
async logout()
|
||||
{
|
||||
await this._get("/api/accounts/logout");
|
||||
this.logged = false;
|
||||
await this._update_logged(false);
|
||||
}
|
||||
|
||||
async _test_logged()
|
||||
@ -120,10 +128,7 @@ class Client
|
||||
let data = await response.json();
|
||||
|
||||
if (data.id !== undefined)
|
||||
{
|
||||
this.me = new Profile(this)
|
||||
await this.me.init(data.id)
|
||||
}
|
||||
await this._update_logged(true);
|
||||
return data.id !== undefined;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user