Admin stuff

This commit is contained in:
Opaque02 2024-09-24 14:14:14 +10:00
parent 2c0fc385bd
commit b802229e60
4 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,6 @@
VITE_BYPASS_LOGIN=1 VITE_BYPASS_LOGIN=0
VITE_BYPASS_TUTORIAL=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_DISCORD_CLIENT_ID=1234567890
VITE_GOOGLE_CLIENT_ID=1234567890 VITE_GOOGLE_CLIENT_ID=1234567890
VITE_I18N_DEBUG=1 VITE_I18N_DEBUG=1

View File

@ -7,6 +7,8 @@ import { Button } from "#app/enums/buttons";
export default class AdminUiHandler extends FormModalUiHandler { export default class AdminUiHandler extends FormModalUiHandler {
private adminMode: string;
private unlinkAction: Function; private unlinkAction: Function;
constructor(scene: BattleScene, mode: Mode | null = null) { constructor(scene: BattleScene, mode: Mode | null = null) {
@ -14,7 +16,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
} }
setup(): void { setup(): void {
super.setup();
} }
getModalTitle(config?: ModalConfig): string { getModalTitle(config?: ModalConfig): string {
@ -22,7 +24,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
} }
getFields(config?: ModalConfig): string[] { getFields(config?: ModalConfig): string[] {
return ["Username", "Discord ID"]; return this.adminMode === "link" ? ["Username", "Discord ID"] : ["Test", "Hello"];
} }
getWidth(config?: ModalConfig): number { getWidth(config?: ModalConfig): number {
@ -34,7 +36,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
} }
getButtonLabels(config?: ModalConfig): string[] { getButtonLabels(config?: ModalConfig): string[] {
return ["Link account", "Unlink account", "Cancel"]; return ["Link account", "Cancel"];
} }
processInput(button: Button): boolean { processInput(button: Button): boolean {
@ -47,7 +49,10 @@ export default class AdminUiHandler extends FormModalUiHandler {
} }
show(args: any[]): boolean { 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 config = args[0] as ModalConfig;
const originalSubmitAction = this.submitAction; const originalSubmitAction = this.submitAction;
let originAction: number = 0; // this is used to keep track of which button has been pressed let originAction: number = 0; // this is used to keep track of which button has been pressed

View File

@ -397,7 +397,7 @@ export default class MenuUiHandler extends MessageUiHandler {
ui.revertMode(); ui.revertMode();
} }
] ]
}); }, "link");
return true; return true;
}, },
keepOpen: true keepOpen: true

View File

@ -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 { export function setCookie(cName: string, cValue: string): void {
const expiration = new Date(); const expiration = new Date();
expiration.setTime(new Date().getTime() + 3600000 * 24 * 30 * 3/*7*/); 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 { export function removeCookie(cName: string): void {
if (isBeta) { 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}=;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;Path=/;Max-Age=-1`; // legacy cookie without domain, for older cookies to prevent a login loop
} }
export function getCookie(cName: string): string { export function getCookie(cName: string): string {