mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-06 18:49:39 +01:00
Minor: Make email check in '/email change' case-insensitive
This commit is contained in:
parent
ba65633182
commit
fbd8049af5
@ -47,7 +47,7 @@ public class AsyncChangeEmail implements AsynchronousProcess {
|
|||||||
service.send(player, MessageKey.USAGE_ADD_EMAIL);
|
service.send(player, MessageKey.USAGE_ADD_EMAIL);
|
||||||
} else if (newEmail == null || !validationService.validateEmail(newEmail)) {
|
} else if (newEmail == null || !validationService.validateEmail(newEmail)) {
|
||||||
service.send(player, MessageKey.INVALID_NEW_EMAIL);
|
service.send(player, MessageKey.INVALID_NEW_EMAIL);
|
||||||
} else if (!oldEmail.equals(currentEmail)) {
|
} else if (!oldEmail.equalsIgnoreCase(currentEmail)) {
|
||||||
service.send(player, MessageKey.INVALID_OLD_EMAIL);
|
service.send(player, MessageKey.INVALID_OLD_EMAIL);
|
||||||
} else if (!validationService.isEmailFreeForRegistration(newEmail, player)) {
|
} else if (!validationService.isEmailFreeForRegistration(newEmail, player)) {
|
||||||
service.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
service.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
|
||||||
|
@ -45,7 +45,7 @@ public class AsyncChangeEmailTest {
|
|||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAddEmail() {
|
public void shouldChangeEmail() {
|
||||||
// given
|
// given
|
||||||
String newEmail = "new@mail.tld";
|
String newEmail = "new@mail.tld";
|
||||||
given(player.getName()).willReturn("Bobby");
|
given(player.getName()).willReturn("Bobby");
|
||||||
@ -65,6 +65,28 @@ public class AsyncChangeEmailTest {
|
|||||||
verify(service).send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
verify(service).send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldNotBeCaseSensitiveWhenComparingEmails() {
|
||||||
|
// given
|
||||||
|
String newEmail = "newmail@example.com";
|
||||||
|
given(player.getName()).willReturn("Debra");
|
||||||
|
given(playerCache.isAuthenticated("debra")).willReturn(true);
|
||||||
|
String oldEmail = "OLD-mail@example.org";
|
||||||
|
PlayerAuth auth = authWithMail(oldEmail);
|
||||||
|
given(playerCache.getAuth("debra")).willReturn(auth);
|
||||||
|
given(dataSource.updateEmail(auth)).willReturn(true);
|
||||||
|
given(validationService.validateEmail(newEmail)).willReturn(true);
|
||||||
|
given(validationService.isEmailFreeForRegistration(newEmail, player)).willReturn(true);
|
||||||
|
|
||||||
|
// when
|
||||||
|
process.changeEmail(player, "old-mail@example.org", newEmail);
|
||||||
|
|
||||||
|
// then
|
||||||
|
verify(dataSource).updateEmail(auth);
|
||||||
|
verify(playerCache).updatePlayer(auth);
|
||||||
|
verify(service).send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldShowErrorIfSaveFails() {
|
public void shouldShowErrorIfSaveFails() {
|
||||||
// given
|
// given
|
||||||
|
Loading…
Reference in New Issue
Block a user