-
Notifications
You must be signed in to change notification settings - Fork 0
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
[PM-11405] Account Management: Prevent a verified user from changing their email address #19
base: main
Are you sure you want to change the base?
[PM-11405] Account Management: Prevent a verified user from changing their email address #19
Conversation
…rifiedUserEmailDomainAsync and refactor to return a list. Remove ManagedByOrganizationId from ProfileResponseMode. Add ManagesActiveUser to ProfileOrganizationResponseModel
…ing their email address
…sManagedByAnyOrganizationAsync to not return nullable objects. Update ProfileOrganizationResponseModel.UserIsManagedByOrganization to not be nullable
…vault' into ac/pm-11405/prevent-a-verified-user-from-changing-their-email-address
…vault' into ac/pm-11405/prevent-a-verified-user-from-changing-their-email-address
…nging-their-email-address
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.
2 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
// If Account Deprovisioning is enabled, we need to check if the user is managed by any organization. | ||
if (_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning) | ||
&& await _userService.IsManagedByAnyOrganizationAsync(user.Id)) | ||
{ | ||
throw new BadRequestException("Cannot change emails for accounts owned by an organization. Contact your organization administrator for additional details."); | ||
} |
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.
style: Consider extracting this check into a separate method for reusability and improved readability
// If Account Deprovisioning is enabled, we need to check if the user is managed by any organization. | ||
if (_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning) | ||
&& await _userService.IsManagedByAnyOrganizationAsync(user.Id)) | ||
{ | ||
throw new BadRequestException("Cannot change emails for accounts owned by an organization. Contact your organization administrator for additional details."); | ||
} |
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.
style: This block is identical to the one in PostEmailToken. Consider refactoring to avoid duplication
var user = GenerateExampleUser(); | ||
ConfigureUserServiceToReturnValidPrincipalFor(user); | ||
ConfigureUserServiceToAcceptPasswordFor(user); | ||
_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning).Returns(true); |
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.
style: Consider using a constant for the feature flag key instead of a string literal
var user = GenerateExampleUser(); | ||
ConfigureUserServiceToReturnValidPrincipalFor(user); | ||
ConfigureUserServiceToAcceptPasswordFor(user); | ||
_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning).Returns(true); |
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.
style: Consider using a constant for the feature flag key instead of a string literal
ConfigureUserServiceToReturnValidPrincipalFor(user); | ||
_userService.ChangeEmailAsync(user, default, default, default, default, default) | ||
.Returns(Task.FromResult(IdentityResult.Success)); | ||
_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning).Returns(true); |
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.
style: Consider using a constant for the feature flag key instead of a string literal
{ | ||
var user = GenerateExampleUser(); | ||
ConfigureUserServiceToReturnValidPrincipalFor(user); | ||
_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning).Returns(true); |
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.
style: Consider using a constant for the feature flag key instead of a string literal
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-11405
📔 Objective
If the Account Deprovisioning feature flag is enabled and the user is managed by an organization then block the Change Email endpoints.
Clients PR: bitwarden/clients#11486
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changesGreptile Summary
This pull request implements a feature to prevent verified users from changing their email addresses when managed by an organization and the Account Deprovisioning feature flag is enabled.
AccountsController.PostEmailToken
andPostEmail
methods to enforce email change restrictions_featureService
to check if Account Deprovisioning feature is enabled_userService.IsManagedByAnyOrganizationAsync
to determine if user is managed by an organizationAccountsControllerTests
with new test cases for Account Deprovisioning scenarios