Skip to content

Commit f8eed8c

Browse files
committed
refactor: separate 'Forgot Password' Dialog ui at pre/join
1 parent 9beb085 commit f8eed8c

42 files changed

Lines changed: 295 additions & 12 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

authme-core/src/main/java/fr/xephi/authme/message/MessageKey.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,18 @@ public enum MessageKey {
553553
/** Two-factor dialog submit button label. */
554554
DIALOG_TWO_FACTOR_BUTTON("dialog.two_factor.button"),
555555

556+
/** Password recovery dialog title. */
557+
DIALOG_RECOVERY_TITLE("dialog.recovery.title"),
558+
559+
/** Password recovery dialog body text shown below the title. */
560+
DIALOG_RECOVERY_BODY("dialog.recovery.body"),
561+
562+
/** Password recovery dialog email field label. */
563+
DIALOG_RECOVERY_EMAIL("dialog.recovery.email"),
564+
565+
/** Password recovery dialog submit button label. */
566+
DIALOG_RECOVERY_BUTTON("dialog.recovery.button"),
567+
556568
/** Generic dialog cancel button label. */
557569
DIALOG_CANCEL_BUTTON("dialog.button.cancel"),
558570

authme-core/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ private void handleWrongPassword(Player player, PlayerAuth auth, String ip) {
275275
}
276276

277277
private void showTotpDialogIfEnabled(Player player) {
278-
if (!service.getProperty(RegistrationSettings.USE_DIALOG_UI) || !dialogAdapter.isDialogSupported()) {
278+
boolean dialogEnabled = service.getProperty(RegistrationSettings.USE_DIALOG_UI)
279+
|| service.getProperty(RegistrationSettings.USE_PREJOIN_DIALOG_UI);
280+
if (!dialogEnabled || !dialogAdapter.isDialogSupported()) {
279281
return;
280282
}
281283

authme-core/src/main/java/fr/xephi/authme/service/DialogWindowService.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,38 @@ public DialogWindowSpec createPreJoinLoginDialog(String playerName) {
5151
boolean showRecovery = commonService.getProperty(RegistrationSettings.DIALOG_SHOW_FORGOT_PASSWORD_BUTTON)
5252
&& emailService.hasAllInformation();
5353
boolean showBody = commonService.getProperty(RegistrationSettings.DIALOG_SHOW_BODY);
54+
Function<MessageKey, String> text = key -> messages.retrieveSingle(playerName, key);
55+
5456
// When recovery is shown it occupies the secondary button slot, so cancel button is suppressed.
5557
// Escape is also disabled: the player must either submit, use recovery, or disconnect.
56-
return createLoginDialogSpec(
57-
key -> messages.retrieveSingle(playerName, key),
58-
showRecovery,
59-
!showRecovery && commonService.getProperty(RegistrationSettings.PRE_JOIN_DIALOG_SHOW_CANCEL_BUTTON),
60-
!showRecovery && commonService.getProperty(RegistrationSettings.PRE_JOIN_DIALOG_ALLOW_CLOSE_WITH_ESCAPE),
61-
showBody);
58+
boolean showCancelButton = !showRecovery && commonService.getProperty(RegistrationSettings.PRE_JOIN_DIALOG_SHOW_CANCEL_BUTTON);
59+
boolean canCloseWithEscape = !showRecovery && commonService.getProperty(RegistrationSettings.PRE_JOIN_DIALOG_ALLOW_CLOSE_WITH_ESCAPE);
60+
61+
// Password field only — email is collected on a separate recovery page if needed
62+
return new DialogWindowSpec(
63+
text.apply(MessageKey.DIALOG_LOGIN_TITLE),
64+
List.of(new DialogInputSpec("password", text.apply(MessageKey.DIALOG_LOGIN_PASSWORD), DEFAULT_MAX_INPUT_LENGTH)),
65+
text.apply(MessageKey.DIALOG_LOGIN_BUTTON),
66+
showRecovery ? text.apply(MessageKey.DIALOG_LOGIN_RECOVERY_BUTTON) : text.apply(MessageKey.DIALOG_CANCEL_BUTTON),
67+
showRecovery || showCancelButton,
68+
canCloseWithEscape,
69+
showRecovery ? "forgot_password" : null,
70+
showBody ? text.apply(MessageKey.DIALOG_LOGIN_BODY) : null);
71+
}
72+
73+
public DialogWindowSpec createPreJoinRecoveryDialog(String playerName) {
74+
boolean showBody = commonService.getProperty(RegistrationSettings.DIALOG_SHOW_BODY);
75+
Function<MessageKey, String> text = key -> messages.retrieveSingle(playerName, key);
76+
77+
return new DialogWindowSpec(
78+
text.apply(MessageKey.DIALOG_RECOVERY_TITLE),
79+
List.of(new DialogInputSpec("email", text.apply(MessageKey.DIALOG_RECOVERY_EMAIL), DEFAULT_MAX_INPUT_LENGTH)),
80+
text.apply(MessageKey.DIALOG_RECOVERY_BUTTON),
81+
text.apply(MessageKey.DIALOG_CANCEL_BUTTON),
82+
true,
83+
false,
84+
null,
85+
showBody ? text.apply(MessageKey.DIALOG_RECOVERY_BODY) : null);
6286
}
6387

6488
public DialogWindowSpec createTotpDialog(Player player) {

authme-core/src/main/resources/messages/messages_bg.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ dialog:
159159
body: '&7Отворете приложението за удостоверяване и въведете 6-цифрения код.'
160160
code: '&f2FA код'
161161
button: '&aПотвърди'
162+
recovery:
163+
title: '&6Възстановяване на парола'
164+
body: '&7Въведете регистрирания имейл адрес и ще ви бъде изпратен код за нулиране.'
165+
email: '&fИмейл адрес'
166+
button: '&aИзпрати имейл за възстановяване'
167+
162168
button:
163169
cancel: '&cОтказ'
164170

authme-core/src/main/resources/messages/messages_br.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ dialog:
177177
body: '&7Abra seu aplicativo de autenticação e insira o código de 6 dígitos.'
178178
code: '&fCódigo 2FA'
179179
button: '&aVerificar'
180+
recovery:
181+
title: '&6Recuperação de Senha'
182+
body: '&7Insira o seu endereço de e-mail cadastrado e um código de redefinição será enviado para você.'
183+
email: '&fEndereço de E-mail'
184+
button: '&aEnviar E-mail de Recuperação'
185+
180186
button:
181187
cancel: '&cCancelar'
182188

authme-core/src/main/resources/messages/messages_cz.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ dialog:
161161
body: '&7Otevřete svou autentizační aplikaci a zadejte 6místný kód.'
162162
code: '&fKód 2FA'
163163
button: '&aOvěřit'
164+
recovery:
165+
title: '&6Obnova hesla'
166+
body: '&7Zadejte svou registrovanou e-mailovou adresu a bude vám zaslán kód pro reset.'
167+
email: '&fE-mailová adresa'
168+
button: '&aOdeslat obnovovací e-mail'
169+
164170
button:
165171
cancel: '&cZrušit'
166172

authme-core/src/main/resources/messages/messages_de.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ dialog:
161161
body: '&7Öffne deine Authentifizierungs-App und gib den 6-stelligen Code ein.'
162162
code: '&f2FA-Code'
163163
button: '&aVerifizieren'
164+
recovery:
165+
title: '&6Passwort-Wiederherstellung'
166+
body: '&7Gib deine registrierte E-Mail-Adresse ein und ein Rücksetzcode wird dir zugeschickt.'
167+
email: '&fE-Mail-Adresse'
168+
button: '&aWiederherstellungs-E-Mail senden'
169+
164170
button:
165171
cancel: '&cAbbrechen'
166172

authme-core/src/main/resources/messages/messages_en.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ dialog:
171171
body: '&7Open your authenticator app and enter the 6-digit code.'
172172
code: '&f2FA Code'
173173
button: '&aVerify'
174+
recovery:
175+
title: '&6Password Recovery'
176+
body: '&7Enter your registered email address and a reset code will be sent to you.'
177+
email: '&fEmail Address'
178+
button: '&aSend Recovery Email'
179+
174180
button:
175181
cancel: '&cCancel'
176182

authme-core/src/main/resources/messages/messages_eo.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ dialog:
161161
body: '&7Malfermu vian aŭtentikigan aplikaĵon kaj enigu la 6-cifran kodon.'
162162
code: '&f2FA-kodo'
163163
button: '&aKonfirmi'
164+
recovery:
165+
title: '&6Restarigo de Pasvorto'
166+
body: '&7Enigu vian registritan retadreson kaj resendkodo estos sendita al vi.'
167+
email: '&fRetadreso'
168+
button: '&aSendi Restarigan Retmesaĝon'
169+
164170
button:
165171
cancel: '&cNuligi'
166172

authme-core/src/main/resources/messages/messages_es.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ dialog:
162162
body: '&7Abre tu aplicación de autenticación e introduce el código de 6 dígitos.'
163163
code: '&fCódigo 2FA'
164164
button: '&aVerificar'
165+
recovery:
166+
title: '&6Recuperación de contraseña'
167+
body: '&7Introduce tu dirección de correo registrada y se te enviará un código de restablecimiento.'
168+
email: '&fDirección de correo'
169+
button: '&aEnviar correo de recuperación'
170+
165171
button:
166172
cancel: '&cCancelar'
167173

0 commit comments

Comments
 (0)