Skip to content

Commit 649e7ee

Browse files
bodom91php-coder
authored andcommitted
/account/activate: strip trailing spaces in login field.
Fix #212
1 parent 91c7bc9 commit 649e7ee

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/java/ru/mystamps/web/controller/AccountController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ protected void registrationInitBinder(WebDataBinder binder) {
6161

6262
@InitBinder("activateAccountForm")
6363
protected void activationInitBinder(WebDataBinder binder) {
64+
binder.registerCustomEditor(String.class, "login", new StringTrimmerEditor(true));
6465
binder.registerCustomEditor(String.class, "name", new StringTrimmerEditor(true));
6566
}
6667

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserActivateAccount.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ public void loginShouldBeUnique() {
151151
.hasError(tr("ru.mystamps.web.validation.jsr303.UniqueLogin.message"));
152152
}
153153

154+
@Test(groups = "misc", dependsOnGroups = "std")
155+
public void loginShouldBeStripedFromLeadingAndTrailingSpaces() {
156+
page.activateAccount(" testLogin ", null, null, null, null);
157+
158+
assertThat(page).field("login").hasValue("testLogin");
159+
}
160+
154161
@Test(groups = "invalid", dependsOnGroups = "std")
155162
public void nameShouldNotBeTooLong() {
156163
page.activateAccount(null, StringUtils.repeat("0", NAME_MAX_LENGTH + 1), null, null, null);

0 commit comments

Comments
 (0)