mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-14 12:22:19 +02:00
fix holding enter spam
This commit is contained in:
parent
14614eb60a
commit
f52e69bf2e
@ -142,27 +142,29 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
|
|||||||
this.processExternalProvider(config);
|
this.processExternalProvider(config);
|
||||||
const originalLoginAction = this.submitAction;
|
const originalLoginAction = this.submitAction;
|
||||||
this.submitAction = (_) => {
|
this.submitAction = (_) => {
|
||||||
// Prevent overlapping overrides on action modification
|
if (globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
|
||||||
this.submitAction = originalLoginAction;
|
// Prevent overlapping overrides on action modification
|
||||||
this.sanitizeInputs();
|
this.submitAction = originalLoginAction;
|
||||||
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
this.sanitizeInputs();
|
||||||
const onFail = error => {
|
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
||||||
globalScene.ui.setMode(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
const onFail = error => {
|
||||||
globalScene.ui.playError();
|
globalScene.ui.setMode(Mode.LOGIN_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
||||||
};
|
globalScene.ui.playError();
|
||||||
if (!this.inputs[0].text) {
|
};
|
||||||
return onFail(i18next.t("menu:emptyUsername"));
|
if (!this.inputs[0].text) {
|
||||||
}
|
return onFail(i18next.t("menu:emptyUsername"));
|
||||||
|
|
||||||
const [ usernameInput, passwordInput ] = this.inputs;
|
|
||||||
|
|
||||||
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text }).then(error => {
|
|
||||||
if (!error) {
|
|
||||||
originalLoginAction && originalLoginAction();
|
|
||||||
} else {
|
|
||||||
onFail(error);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
const [ usernameInput, passwordInput ] = this.inputs;
|
||||||
|
|
||||||
|
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text }).then(error => {
|
||||||
|
if (!error) {
|
||||||
|
originalLoginAction && originalLoginAction();
|
||||||
|
} else {
|
||||||
|
onFail(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -91,43 +91,45 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
|
|||||||
|
|
||||||
const originalRegistrationAction = this.submitAction;
|
const originalRegistrationAction = this.submitAction;
|
||||||
this.submitAction = (_) => {
|
this.submitAction = (_) => {
|
||||||
// Prevent overlapping overrides on action modification
|
if (globalScene.tweens.getTweensOf(this.modalContainer).length === 0) {
|
||||||
this.submitAction = originalRegistrationAction;
|
// Prevent overlapping overrides on action modification
|
||||||
this.sanitizeInputs();
|
this.submitAction = originalRegistrationAction;
|
||||||
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
this.sanitizeInputs();
|
||||||
const onFail = error => {
|
globalScene.ui.setMode(Mode.LOADING, { buttonActions: []});
|
||||||
globalScene.ui.setMode(Mode.REGISTRATION_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
const onFail = error => {
|
||||||
globalScene.ui.playError();
|
globalScene.ui.setMode(Mode.REGISTRATION_FORM, Object.assign(config, { errorMessage: error?.trim() }));
|
||||||
const errorMessageFontSize = languageSettings[i18next.resolvedLanguage!]?.errorMessageFontSize;
|
globalScene.ui.playError();
|
||||||
if (errorMessageFontSize) {
|
const errorMessageFontSize = languageSettings[i18next.resolvedLanguage!]?.errorMessageFontSize;
|
||||||
this.errorMessage.setFontSize(errorMessageFontSize);
|
if (errorMessageFontSize) {
|
||||||
}
|
this.errorMessage.setFontSize(errorMessageFontSize);
|
||||||
};
|
|
||||||
if (!this.inputs[0].text) {
|
|
||||||
return onFail(i18next.t("menu:emptyUsername"));
|
|
||||||
}
|
|
||||||
if (!this.inputs[1].text) {
|
|
||||||
return onFail(this.getReadableErrorMessage("invalid password"));
|
|
||||||
}
|
|
||||||
if (this.inputs[1].text !== this.inputs[2].text) {
|
|
||||||
return onFail(i18next.t("menu:passwordNotMatchingConfirmPassword"));
|
|
||||||
}
|
|
||||||
const [ usernameInput, passwordInput ] = this.inputs;
|
|
||||||
pokerogueApi.account.register({ username: usernameInput.text, password: passwordInput.text })
|
|
||||||
.then(registerError => {
|
|
||||||
if (!registerError) {
|
|
||||||
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text })
|
|
||||||
.then(loginError => {
|
|
||||||
if (!loginError) {
|
|
||||||
originalRegistrationAction && originalRegistrationAction();
|
|
||||||
} else {
|
|
||||||
onFail(loginError);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
onFail(registerError);
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
if (!this.inputs[0].text) {
|
||||||
|
return onFail(i18next.t("menu:emptyUsername"));
|
||||||
|
}
|
||||||
|
if (!this.inputs[1].text) {
|
||||||
|
return onFail(this.getReadableErrorMessage("invalid password"));
|
||||||
|
}
|
||||||
|
if (this.inputs[1].text !== this.inputs[2].text) {
|
||||||
|
return onFail(i18next.t("menu:passwordNotMatchingConfirmPassword"));
|
||||||
|
}
|
||||||
|
const [ usernameInput, passwordInput ] = this.inputs;
|
||||||
|
pokerogueApi.account.register({ username: usernameInput.text, password: passwordInput.text })
|
||||||
|
.then(registerError => {
|
||||||
|
if (!registerError) {
|
||||||
|
pokerogueApi.account.login({ username: usernameInput.text, password: passwordInput.text })
|
||||||
|
.then(loginError => {
|
||||||
|
if (!loginError) {
|
||||||
|
originalRegistrationAction && originalRegistrationAction();
|
||||||
|
} else {
|
||||||
|
onFail(loginError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
onFail(registerError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user