-
Notifications
You must be signed in to change notification settings - Fork 1
HEEDLS-350 Validate password if not null before ModelState validation #469
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
Conversation
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.
Looks all good for now, but I have left a question about refactoring to reduce potentially redundant duplicated calls.
|
|
||
| // When | ||
| var result = await authenticatedController.Index(new ChangePasswordViewModel()); | ||
| var result = await authenticatedController.Index(new ChangePasswordViewModel{CurrentPassword = "test"}); |
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.
Minor, but could we run the formatter?
| } | ||
| userService.UpdateUserAccountDetails(accountDetailsData, centreAnswersData); | ||
|
|
||
| return RedirectToAction("Index"); |
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.
Is it worth writing tests for the functionality change?
| return View(model); | ||
| } | ||
|
|
||
| var verifiedLinkedUsersAccounts = |
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.
Given that we need the verifiedLinkedUserAccounts anyway, could we do something like:
var verifiedLinkedUsersAccounts = string.IsNullOrEmpty(model.CurrentPassword)
? new UserAccountSet()
: userService.GetVerifiedLinkedUsersAccounts(adminId, delegateId, model.CurrentPassword!);
if (verifiedLinkedUsersAccounts.Any()) {
// Add errors
}
Then we can continue without having to make 2x calls to getting linked accounts. Will probably be more work than worth to avoid double calls on the MyAccountController though.
| if (model.CurrentPassword != null && !userService.IsPasswordValid(adminId, delegateId, model.CurrentPassword)) | ||
|
|
||
| var verifiedLinkedUsersAccounts = string.IsNullOrEmpty(model.CurrentPassword) | ||
| ? new UserAccountSet(null, null) |
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.
Super minor, but is it worth adding an empty constructor to UserAccountSet?
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.
Looks good - a single comment about UserAccountSet (as it's user in tests too), but no need for rereview 👍
Moved the validation of the password if it isn't null before the ModelState.IsValid check for both the ChangePassword and MyAccount EditDetails so that the user is shown the invalid current password error even if they also have other validation errors.