Skip to content

Conversation

@AlexJacksonDS
Copy link
Contributor

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.

Copy link
Contributor

@DanBloxham-sw DanBloxham-sw left a 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"});
Copy link
Contributor

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");
Copy link
Contributor

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 =
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor

@stellake stellake left a 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 👍

@AlexJacksonDS AlexJacksonDS merged commit 2753c94 into master Jul 8, 2021
@AlexJacksonDS AlexJacksonDS deleted the HEEDLS-350-change-password-validation branch July 8, 2021 11:18
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.

3 participants