If recovery code is required, dont send new password

This commit is contained in:
EbonJaguar 2017-03-22 17:11:18 -04:00
parent 46dd588923
commit 4053a0e328
33 changed files with 59 additions and 63 deletions

View File

@ -1,8 +1,6 @@
package fr.xephi.authme.command.executable.email;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.PasswordRecoveryService;
@ -20,9 +18,6 @@ public class ProcessCodeCommand extends PlayerCommand {
@Inject
private CommonService commonService;
@Inject
private DataSource dataSource;
@Inject
private RecoveryCodeService codeService;
@ -36,14 +31,8 @@ public class ProcessCodeCommand extends PlayerCommand {
if (codeService.hasTriesLeft(name)) {
if (codeService.isCodeValid(name, code)) {
PlayerAuth auth = dataSource.getAuth(name);
String email = auth.getEmail();
if (email == null || "your@email.com".equalsIgnoreCase(email)) {
commonService.send(player, MessageKey.INVALID_EMAIL);
return;
}
recoveryService.generateAndSendNewPassword(player, email);
commonService.send(player, MessageKey.RECOVERY_CODE_CORRECT);
recoveryService.addSuccessfulRecovery(player);
codeService.removeCode(name);
} else {
commonService.send(player, MessageKey.INCORRECT_RECOVERY_CODE,

View File

@ -66,9 +66,10 @@ public class RecoverEmailCommand extends PlayerCommand {
}
if (recoveryCodeService.isRecoveryCodeNeeded()) {
// Process /email recovery addr@example.com
// Recovery code is needed; generate and send one
recoveryService.createAndSendRecoveryCode(player, email);
} else {
// Code not needed, just send them a new password
recoveryService.generateAndSendNewPassword(player, email);
}
}

View File

@ -230,6 +230,9 @@ public enum MessageKey {
/** You have exceeded the maximum number of attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one. */
RECOVERY_TRIES_EXCEEDED("recovery_tries_exceeded"),
/** Recovery code entered correctly! */
RECOVERY_CODE_CORRECT("recovery_code_correct"),
/** Please use the command /email setpassword to change your password immediately. */
RECOVERY_CHANGE_PASSWORD("recovery_change_password"),

View File

@ -101,16 +101,25 @@ public class PasswordRecoveryService implements Reloadable {
if (couldSendMail) {
commonService.send(player, MessageKey.RECOVERY_EMAIL_SENT_MESSAGE);
emailCooldown.add(player.getName().toLowerCase());
String address = PlayerUtils.getPlayerIp(player);
successfulRecovers.put(name, address);
commonService.send(player, MessageKey.RECOVERY_CHANGE_PASSWORD);
} else {
commonService.send(player, MessageKey.EMAIL_SEND_FAILURE);
}
}
/**
* Allows a player to change their password after
* correctly entering a recovery code.
*
* @param player The player recovering their password.
*/
public void addSuccessfulRecovery(Player player) {
String name = player.getName();
String address = PlayerUtils.getPlayerIp(player);
successfulRecovers.put(name, address);
commonService.send(player, MessageKey.RECOVERY_CHANGE_PASSWORD);
}
/**
* Check if a player is able to have emails sent.
*

View File

@ -44,12 +44,12 @@ accounts_owned_self: 'Претежаваш %count акаунт/а:'
accounts_owned_other: 'Потребителят %name има %count акаунт/а:'
two_factor_create: '&2Кода е %code. Можеш да го провериш оттука: %url'
recovery_code_sent: 'Възстановяващият код беше изпратен на твоят email адрес.'
# TODO: Missing tags %count
recovery_code_incorrect: 'Възстановяващият код е неправилен! Използвайте: /email recovery имейл, за да генерирате нов'
vb_nonActiv: '&cТвоят акаунт все още не е актириван, моля провете своят email адрес!'
unregistered: '&cУспешно от-регистриран!'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fТвоята регистрация не е активирана, моля провери своя Имейл!'
vb_nonActiv: '&cТвоят акаунт все още не е актириван, моля провете своят email адрес!'
usage_unreg: '&cКоманда: /unregister парола'
pwd_changed: '&2Паротала е променена успешно!'
logged_in: '&cВече си вписан!'

View File

@ -51,6 +51,7 @@ recovery_code_sent: 'Um código de recuperação para redefinir sua senha foi en
# TODO: Missing tags %count
recovery_code_incorrect: 'O código de recuperação esta incorreto! Use /email recovery [email] para gerar um novo!'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cA sua conta ainda não está ativada, por favor, verifique seus e-mails!'
usage_unreg: '&cUse: /unregister <senha>'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'Kód pro obnovení hesla byl odeslán na váš email.'
# TODO: Missing tags %count
recovery_code_incorrect: 'Kód pro není správný! Použijte příkaz /email recovery [email] pro vygenerování nového.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cTvůj účet není aktivovaný, zkontroluj si svůj E-mail.'
usage_unreg: '&cPoužij: "/unregister TvojeHeslo".'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'Ein Wiederherstellungscode zum Zurücksetzen deines Passwor
# TODO: Missing tags %count
recovery_code_incorrect: 'Der Wiederherstellungscode stimmt nicht! Nutze /email recovery [email] um einen neuen zu generieren.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cDein Account wurde noch nicht aktiviert. Bitte prüfe deine E-Mails!'
usage_unreg: '&cBenutze: /unregister <passwort>'

View File

@ -46,6 +46,7 @@ two_factor_create: '&2Your secret code is %code. You can scan it from here %url'
recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
recovery_code_correct: 'Recovery code entered correctly!'
recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cYour account isn''t activated yet, please check your emails!'
usage_unreg: '&cUsage: /unregister <password>'

View File

@ -50,6 +50,7 @@ recovery_code_sent: 'El código de recuperación para recuperar tu contraseña s
# TODO: Missing tags %count
recovery_code_incorrect: '¡El código de recuperación no es correcto! Usa "/email recovery [email]" para generar uno nuevo'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fTu cuenta no está activada aún, ¡revisa tu correo!'
usage_unreg: '&cUso: /unregister contraseña'

View File

@ -47,6 +47,7 @@ unregistered: '&cZure erregistroa ezabatu duzu!'
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fZure kontua aktibatu gabe dago, konfirmatu zure emaila!'
usage_unreg: '&cErabili: /unregister password'

View File

@ -47,6 +47,7 @@ unregistered: '&cPelaajatili poistettu onnistuneesti!'
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fKäyttäjäsi ei ole vahvistettu!'
usage_unreg: '&cKäyttötapa: /unregister password'

View File

@ -52,6 +52,7 @@ recovery_code_sent: 'Un code de récupération a été envoyé à votre adresse
# TODO: Missing tags %count
recovery_code_incorrect: '&cLe code de réinitialisation est incorrect!%nl%Faites "/email recovery [email]" pour en générer un nouveau.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fCe compte n''est pas actif, consultez vos emails !'
usage_unreg: '&cPour supprimer votre compte, utilisez "/unregister <MotDePasse>"'

View File

@ -47,6 +47,7 @@ unregistered: '&cFeito! Xa non estás rexistrado!'
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fA túa conta aínda non está activada, comproba a túa bandexa de correo!!'
usage_unreg: '&cUso: /unregister <contrasinal>'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'A jelszavad visszaállításához szükséges kódot sikere
# TODO: Missing tags %count
recovery_code_incorrect: 'A visszaállító kód helytelen volt! Használd a következő parancsot: /email recovery [email címed] egy új generálásához'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cA felhasználód aktiválása még nem történt meg, ellenőrizd a megadott emailed!'
usage_unreg: '&cHasználat: "/unregister <jelszó>"'

View File

@ -47,6 +47,7 @@ unregistered: '&cUnregister berhasil!'
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cAkunmu belum diaktifkan, silahkan periksa email kamu!'
# TODO usage_unreg: '&cUsage: /unregister <password>'

View File

@ -49,6 +49,7 @@ recovery_code_sent: 'Una email contenente il codice di recupero per reimpostare
# TODO: Missing tags %count
recovery_code_incorrect: 'Il codice di recupero inserito non è corretto! Scrivi "/email recovery <email>" per generarne uno nuovo'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cIl tuo account non è stato ancora verificato, controlla fra le tue email per scoprire come attivarlo!'
usage_unreg: '&cUtilizzo: /unregister <password>'

View File

@ -51,6 +51,7 @@ unregistered: '&c성공적으로 탈퇴했습니다!'
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&f당신의 계정은 아직 활성화되어있지 않습니다, 당신의 이메일을 확인해보세요!'
usage_unreg: '&c사용법: /unregister 비밀번호'

View File

@ -47,6 +47,7 @@ unregistered: '&aSekmingai issiregistravote!'
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&aJusu vartotojas nera patvirtintas, patikrinkite el.pasta.'
usage_unreg: '&ePanaikinti registracija: "/unregister slaptazodis"'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'Een herstelcode voor je wachtwoord is naar je mailbox gestu
# TODO: Missing tags %count
recovery_code_incorrect: 'De herstelcode is niet correct! Gebruik "/email recovery [email]" om een nieuwe te krijgen'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: 'Je account is nog niet geactiveerd, controleer je mailbox!'
usage_unreg: '&cGebruik: /unregister password'

View File

@ -48,6 +48,7 @@ recovery_code_sent: 'Kod odzyskiwania hasla zostal wyslany na adres email przypi
# TODO: Missing tags %count
recovery_code_incorrect: 'Kod odzyskiwania hasla jest bledny! Uzyj /email recovery [email] aby wygenerowac nowy.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fTwoje konto nie zostalo aktywowane! Sprawdz maila.'
usage_unreg: '&cUzycie: /unregister haslo'

View File

@ -45,8 +45,10 @@ accounts_owned_self: 'Você possui %count contas:'
accounts_owned_other: 'O jogador %name possui %count contas:'
two_factor_create: '&2O seu código secreto é o %code. Você pode verificá-lo a partir daqui %url'
recovery_code_sent: 'O codigo para redefinir a senha foi enviado para o seu e-mail.'
# TODO: Missing tags %count
recovery_code_incorrect: 'O codigo de recuperação está incorreto! Use "/email recovery [email]" para gerar um novo'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fA sua conta não foi ainda activada, verifique o seu email onde irá receber indicações para activação de conta. '
usage_unreg: '&cUse: /unregister <password>'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'Un cod de recuperare a parolei a fost trimis catre email-ul
# TODO: Missing tags %count
recovery_code_incorrect: 'Codul de recuperare nu este corect! Foloseste /email recovery [email] pentru a genera unul nou.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cContul tau nu este activat, te rugam verifica-ti email-ul!'
usage_unreg: '&cFoloseste comanda: /unregister <parola>'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'Код восстановления для сброса п
# TODO: Missing tags %count
recovery_code_incorrect: 'Код восстановления неверный! Введите /email recovery <Ваш Email>, чтобы отправить новый код'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&6Ваш аккаунт еще не активирован! Проверьте вашу почту!'
usage_unreg: '&cИспользование: &e/unregister <Пароль>'

View File

@ -51,6 +51,7 @@ unregistered: '&cUcet bol vymazany!'
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&fUcet nie je aktivny. Prezri si svoj e-mail!'
usage_unreg: '&cPríkaz: /unregister heslo'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'Sifre sifirlama kodu eposta adresinize gonderildi.'
# TODO: Missing tags %count
recovery_code_incorrect: 'Kod dogru degil! Kullanim "/email recovery [eposta]" ile yeni bir kod olustur'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cHeabiniz henuz aktif edilmemis, e-postanizi kontrol edin!'
usage_unreg: '&cKullanim: /unregister <sifre>'

View File

@ -46,6 +46,7 @@ two_factor_create: '&2Ваш секретний код — %code %nl%&2Може
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cВаш акаунт ще не активовано. Будь ласка, провірте свою електронну пошту!'
usage_unreg: '&cСинтаксис: /unregister <пароль>'

View File

@ -47,6 +47,7 @@ recovery_code_sent: 'Một mã khôi phục mật khẩu đã được gửi đ
# TODO: Missing tags %count
recovery_code_incorrect: 'Mã khôi phục không đúng! Dùng lệnh /email recovery [email] để tạo một mã mới'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&cTài khoản của bạn chưa được kích hoạt, vui lòng kiểm tra email!'
usage_unreg: '&cSử dụng: /unregister <mật khẩu>'

View File

@ -48,6 +48,7 @@ recovery_code_sent: '一个用于重置您的密码的验证码已发到您的
# TODO: Missing tags %count
recovery_code_incorrect: '验证码不正确! 使用 /email recovery [email] 以生成新的验证码'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&8[&6玩家系统&8] &f你的帐号还未激活请查看你的邮箱'
usage_unreg: '&8[&6玩家系统&8] &c正确用法“/unregister <密码>”'

View File

@ -51,6 +51,7 @@ two_factor_create: '&8[&6用戶系統 - 兩步驗證碼&8] &b你的登入金鑰
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&8[&6用戶系統&8] &f你的帳戶還沒有經過電郵驗證 '
usage_unreg: '&8[&6用戶系統&8] &f用法 《 /unregister <密碼> 》'

View File

@ -47,6 +47,7 @@ recovery_code_sent: '已將重設密碼的恢復代碼發送到您的電子郵
# TODO: Missing tags %count
recovery_code_incorrect: '恢復代碼錯誤!使用指令: "/email recovery [電郵地址]" 生成新的一個恢復代碼。'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&c你的帳戶未激活,請確認電郵!'
usage_unreg: '&c使用方法: "/unregister <你的密碼>"'

View File

@ -51,6 +51,7 @@ two_factor_create: '&b【AuthMe - 兩步驗證碼】&b你的登入金鑰為&9「
# TODO recovery_code_sent: 'A recovery code to reset your password has been sent to your email.'
# TODO recovery_code_incorrect: 'The recovery code is not correct! You have %count tries remaining.'
# TODO recovery_tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.'
# TODO recovery_code_correct: 'Recovery code entered correctly!'
# TODO recovery_change_password: 'Please use the command /email setpassword <new password> to change your password immediately.'
vb_nonActiv: '&b【AuthMe】&6你的帳號還沒有經過驗證! 檢查看看你的電子信箱 (Email) 吧!'
usage_unreg: '&b【AuthMe】&6用法: &c"/unregister <密碼>"'

View File

@ -1,7 +1,5 @@
package fr.xephi.authme.command.executable.email;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.PasswordRecoveryService;
@ -32,17 +30,12 @@ public class ProcessCodeCommandTest {
@Mock
private CommonService commonService;
@Mock
private DataSource dataSource;
@Mock
private RecoveryCodeService codeService;
@Mock
private PasswordRecoveryService recoveryService;
private static final String DEFAULT_EMAIL = "your@email.com";
@Test
public void shouldSendErrorForInvalidRecoveryCode() {
// given
@ -79,48 +72,21 @@ public class ProcessCodeCommandTest {
}
@Test
public void shouldHandleDefaultEmail() {
public void shouldProcessCorrectCode() {
// given
String name = "Tract0r";
String name = "Dwight";
String code = "chickenDinner";
Player sender = mock(Player.class);
given(sender.getName()).willReturn(name);
given(dataSource.getAuth(name)).willReturn(newAuthWithEmail(DEFAULT_EMAIL));
given(codeService.hasTriesLeft(name)).willReturn(true);
given(codeService.isCodeValid(name, "actual")).willReturn(true);
given(codeService.isCodeValid(name, code)).willReturn(true);
// when
command.executeCommand(sender, Collections.singletonList("actual"));
command.runCommand(sender, Collections.singletonList(code));
// then
verify(dataSource).getAuth(name);
verifyNoMoreInteractions(dataSource);
verify(commonService).send(sender, MessageKey.INVALID_EMAIL);
}
@Test
public void shouldGenerateAndSendPassword() {
// given
String name = "GenericName";
Player sender = mock(Player.class);
given(sender.getName()).willReturn(name);
String email = "ran-out@example.com";
PlayerAuth auth = newAuthWithEmail(email);
given(dataSource.getAuth(name)).willReturn(auth);
given(codeService.hasTriesLeft(name)).willReturn(true);
given(codeService.isCodeValid(name, "actual")).willReturn(true);
// when
command.executeCommand(sender, Collections.singletonList("actual"));
// then
verify(recoveryService).generateAndSendNewPassword(sender, email);
verify(commonService).send(sender, MessageKey.RECOVERY_CODE_CORRECT);
verify(recoveryService).addSuccessfulRecovery(sender);
verify(codeService).removeCode(name);
}
private static PlayerAuth newAuthWithEmail(String email) {
return PlayerAuth.builder()
.name("name")
.email(email)
.build();
}
}