From b802229e60e2f0467619180261f77ae49e212a7f Mon Sep 17 00:00:00 2001 From: Opaque02 <66582645+Opaque02@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:14:14 +1000 Subject: [PATCH] Admin stuff --- .env.development | 4 ++-- src/ui/admin-ui-handler.ts | 13 +++++++++---- src/ui/menu-ui-handler.ts | 2 +- src/utils.ts | 8 ++++---- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.env.development b/.env.development index 6c92036270f..7ca492fae4c 100644 --- a/.env.development +++ b/.env.development @@ -1,6 +1,6 @@ -VITE_BYPASS_LOGIN=1 +VITE_BYPASS_LOGIN=0 VITE_BYPASS_TUTORIAL=0 -VITE_SERVER_URL=http://localhost:8001 +VITE_SERVER_URL=http://192.168.1.101:8001 VITE_DISCORD_CLIENT_ID=1234567890 VITE_GOOGLE_CLIENT_ID=1234567890 VITE_I18N_DEBUG=1 diff --git a/src/ui/admin-ui-handler.ts b/src/ui/admin-ui-handler.ts index b163ec75157..b568fda8382 100644 --- a/src/ui/admin-ui-handler.ts +++ b/src/ui/admin-ui-handler.ts @@ -7,6 +7,8 @@ import { Button } from "#app/enums/buttons"; export default class AdminUiHandler extends FormModalUiHandler { + private adminMode: string; + private unlinkAction: Function; constructor(scene: BattleScene, mode: Mode | null = null) { @@ -14,7 +16,7 @@ export default class AdminUiHandler extends FormModalUiHandler { } setup(): void { - super.setup(); + } getModalTitle(config?: ModalConfig): string { @@ -22,7 +24,7 @@ export default class AdminUiHandler extends FormModalUiHandler { } getFields(config?: ModalConfig): string[] { - return ["Username", "Discord ID"]; + return this.adminMode === "link" ? ["Username", "Discord ID"] : ["Test", "Hello"]; } getWidth(config?: ModalConfig): number { @@ -34,7 +36,7 @@ export default class AdminUiHandler extends FormModalUiHandler { } getButtonLabels(config?: ModalConfig): string[] { - return ["Link account", "Unlink account", "Cancel"]; + return ["Link account", "Cancel"]; } processInput(button: Button): boolean { @@ -47,7 +49,10 @@ export default class AdminUiHandler extends FormModalUiHandler { } show(args: any[]): boolean { - if (super.show(args)) { + this.adminMode = args[args.length - 1]; + super.setup(); + + if (super.show(args.slice(0, -1))) { const config = args[0] as ModalConfig; const originalSubmitAction = this.submitAction; let originAction: number = 0; // this is used to keep track of which button has been pressed diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 4725bd5fc4e..c162415accb 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -397,7 +397,7 @@ export default class MenuUiHandler extends MessageUiHandler { ui.revertMode(); } ] - }); + }, "link"); return true; }, keepOpen: true diff --git a/src/utils.ts b/src/utils.ts index 7decf9bb4c0..decda017d94 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -283,16 +283,16 @@ export const isBeta = import.meta.env.MODE === "beta"; // this checks to see if export function setCookie(cName: string, cValue: string): void { const expiration = new Date(); expiration.setTime(new Date().getTime() + 3600000 * 24 * 30 * 3/*7*/); - document.cookie = `${cName}=${cValue};Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Expires=${expiration.toUTCString()}`; + document.cookie = `${cName}=${cValue};SameSite=Strict;Domain=${window.location.hostname};Path=/;Expires=${expiration.toUTCString()}`; } export function removeCookie(cName: string): void { if (isBeta) { - document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=pokerogue.net;Path=/;Max-Age=-1`; // we need to remove the cookie from the main domain as well + document.cookie = `${cName}=;SameSite=Strict;Domain=pokerogue.net;Path=/;Max-Age=-1`; // we need to remove the cookie from the main domain as well } - document.cookie = `${cName}=;Secure;SameSite=Strict;Domain=${window.location.hostname};Path=/;Max-Age=-1`; - document.cookie = `${cName}=;Secure;SameSite=Strict;Path=/;Max-Age=-1`; // legacy cookie without domain, for older cookies to prevent a login loop + document.cookie = `${cName}=;SameSite=Strict;Domain=${window.location.hostname};Path=/;Max-Age=-1`; + document.cookie = `${cName}=;SameSite=Strict;Path=/;Max-Age=-1`; // legacy cookie without domain, for older cookies to prevent a login loop } export function getCookie(cName: string): string {