mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-08-20 04:27:29 +00:00
fix(lceonline): being logged out every app open
This commit is contained in:
parent
d536a6590b
commit
ab07f26dcb
|
|
@ -36,9 +36,6 @@ export class LceOnlineService {
|
|||
private _listeners: Array<() => void> = [];
|
||||
constructor() {
|
||||
this.loadSession();
|
||||
if (this._session) {
|
||||
this.refreshToken();
|
||||
}
|
||||
}
|
||||
|
||||
onSessionChange(listener: () => void): () => void {
|
||||
|
|
@ -211,28 +208,6 @@ export class LceOnlineService {
|
|||
return data;
|
||||
}
|
||||
|
||||
async refreshToken(): Promise<boolean> {
|
||||
if (!this._session) return false;
|
||||
|
||||
try {
|
||||
const res = await this.request<string>("POST", "/refreshtoken", null, AUTH_BASE_URL);
|
||||
if (typeof res === "string" && res.startsWith("-")) {
|
||||
const [username, token] = res.slice(1).split(":");
|
||||
this._session.accessToken = token;
|
||||
this._session.account = { username, displayName: username };
|
||||
this.saveSession();
|
||||
this._notify();
|
||||
return true;
|
||||
}
|
||||
this.logoutLocal();
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.warn("Failed to refresh token", e);
|
||||
this.logoutLocal()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async getSocialLists() {
|
||||
const res = await this.request<SocialList>("GET", "/getSocialLists", null);
|
||||
if (typeof res === "string") throw new Error(res);
|
||||
|
|
|
|||
Loading…
Reference in a new issue