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
@@ -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,
@@ -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);
}
}