Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JC-2379 Clear password and passwordConfirm fields when they're different during new user registration #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lekarto
Copy link

@lekarto lekarto commented Dec 20, 2016

No description provided.

@@ -341,7 +341,12 @@ public BindingResult register(RegisterUserDto registerUserDto)
}

if(result.hasErrors()) {
userDto.setPassword(notEncodedPassword);
if (wrongPasswordConfirmError(result)) {
removePasswords(registerUserDto);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removePasswordsFromForm?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that it's correct to mix layers. TransactionalAuthenticator wouldn't know about form. Proposed method name just for programmer and can tangle.

@@ -446,5 +451,36 @@ public JCUser storeRegisteredUser(UserDto userDto) {
LOGGER.info("JCUser registered: {}", user.getUsername());
return user;
}


private void removePasswords(final RegisterUserDto registerUserDto) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add JavaDocs explaining what this does and why it's needed.

Also, we don't have a habit to put final for local vars and parameters :)

registerUserDto.getUserDto().setPassword(null);
}

private BindingResult removeWrongPasswordConfirmError(BindingResult srcErrors) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaDocs for this too

@Test
public void userMustSetToNullPasswordAndPasswordConfirmFieldsWhenTheyAreDifferent() throws Exception {

Validator customValidator = new Validator() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you use the usual validator that's used in prod code?

@@ -486,6 +494,60 @@ public void userMustHaveInitialFieldValuesWhenPluginRegistrationFailWithRegistra
assertReflectionEquals(expectedRegisterUserDto, registerUserDto);
}

@Test
public void userMustSetToNullPasswordAndPasswordConfirmFieldsWhenTheyAreDifferent() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emptiesPassowordAndConfirmationFields_ifTheyDoNotMatch

Maybe let's add some javadocs here explaining why it behaves like this.

}

@Test
public void userMustRestorePasswordAndPasswordConfirmFieldsWhenTheyAreEquals() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesNotEmptyPasswordAndConfirmationFields_ifTheyMatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants