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
8140 fixed username validation federated account creation #8141
8140 fixed username validation federated account creation #8141
Conversation
@djbrooke It seems CI is failing, I made sure to merge the latest from develop. Any idea what is causing it? |
@mderuijter, -- Jim Error |
…ame-validation-federated-account-creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to put the userNameFound method into the UserNameValidator? I know we probably can't put it into the isValid method because we want to show different error messages, but it might be good for code consolidation.
@mderuijter - what do you think about the feedback from @sekmiller above? |
@sekmiller @djbrooke it does make sense to combine the two, let me put it on the to do list |
@mderuijter - #8151 fixes the test failure you saw previously. I'm not sure how/why your branch doesn't show a failure now as the test is truly broken. In any case - merging with dev now should be a real fix. |
@@ -33,7 +33,7 @@ public boolean isValid(String value, ConstraintValidatorContext context) { | |||
* @param username | |||
* @return boolean | |||
*/ | |||
public static boolean isUserNameValid(final String username, ConstraintValidatorContext context) { | |||
public static boolean isUserNameValid(final String username) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the ConstraintValidatorContext removed because it was never used? If so, @sekmiller do you happen to recall why it may have been there? And if so should we also then remove it from the isValid method above? (this would mean finding all calls to it, of course)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scolapasta It was removed because it was not being used indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems not to have been used at all and should probably be removed from isValid. Not sure why it was in there in the first place. It looks like Sarah wrote the original code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mderuijter since there's no reason to have the context in the isValid method, would you be able to remove it there (and refactor calls to it) as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scolapasta I see this will result in removing the entire implements ConstraintValidator<ValidateUserName, String>
Interface structure as well, which leads to a related problem in ValidateUserName.java
as well. Which in turn is used in BuiltinUser.java
line 48. So eventhough the context parameter is not used, the surrounding structure is. I'm not entirely sure how to refactor that properly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok! that makes sense. I went ahead and added a comment in order to clarify this for when we look at this down the line.
…ame-validation-federated-account-creation
@sekmiller I had a look at the code again and I'm assuming you mean the method call of the AuthenticationService at Line 242 in 6f47e5d
authenticationSvc.identifierExists(userName) so you can return different FacesMessages.
I'm not sure there's a lot to win here by moving that around to be honest |
OK @mderuijter, point taken. My hope was to have all of the validation logic in one place, but I see the pitfalls. I'll approve the PR but let Gustavo make the final call on passing to QA. |
src/main/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/OAuth2FirstLoginPage.java
Outdated
Show resolved
Hide resolved
…ame-validation-federated-account-creation
What this PR does / why we need it:
Fixes username validation for federated account creation
Which issue(s) this PR closes:
Closes #8140
Special notes for your reviewer:
None
Suggestions on how to test this:
Please see steps explained in the related issue
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No
Is there a release notes update needed for this change?:
No
Additional documentation: