1- using Bit . Core ;
2- using Bit . Core . Auth . Entities ;
1+ using Bit . Core . Auth . Entities ;
32using Bit . Core . Auth . Enums ;
43using Bit . Core . Auth . Models . Api . Response ;
54using Bit . Core . Auth . Utilities ;
87using Bit . Core . Enums ;
98using Bit . Core . KeyManagement . Models . Api . Response ;
109using Bit . Core . Repositories ;
11- using Bit . Core . Services ;
1210using Bit . Core . Utilities ;
1311using Bit . Identity . Utilities ;
1412
@@ -26,8 +24,6 @@ public class UserDecryptionOptionsBuilder : IUserDecryptionOptionsBuilder
2624 private readonly IDeviceRepository _deviceRepository ;
2725 private readonly IOrganizationUserRepository _organizationUserRepository ;
2826 private readonly ILoginApprovingClientTypes _loginApprovingClientTypes ;
29- private readonly IFeatureService _featureService ;
30-
3127 private UserDecryptionOptions _options = new UserDecryptionOptions ( ) ;
3228 private User _user = null ! ;
3329 private SsoConfig ? _ssoConfig ;
@@ -37,15 +33,13 @@ public UserDecryptionOptionsBuilder(
3733 ICurrentContext currentContext ,
3834 IDeviceRepository deviceRepository ,
3935 IOrganizationUserRepository organizationUserRepository ,
40- ILoginApprovingClientTypes loginApprovingClientTypes ,
41- IFeatureService featureService
36+ ILoginApprovingClientTypes loginApprovingClientTypes
4237 )
4338 {
4439 _currentContext = currentContext ;
4540 _deviceRepository = deviceRepository ;
4641 _organizationUserRepository = organizationUserRepository ;
4742 _loginApprovingClientTypes = loginApprovingClientTypes ;
48- _featureService = featureService ;
4943 }
5044
5145 public IUserDecryptionOptionsBuilder ForUser ( User user )
@@ -145,35 +139,8 @@ private async Task BuildTrustedDeviceOptionsAsync()
145139 // In the TDE flow, the users will have been JIT-provisioned at SSO callback time, and the relationship between
146140 // user and organization user will have been codified.
147141 var organizationUser = await _organizationUserRepository . GetByOrganizationAsync ( _ssoConfig . OrganizationId , _user . Id ) ;
148- var hasManageResetPasswordPermission = false ;
149- if ( _featureService . IsEnabled ( FeatureFlagKeys . PM23174ManageAccountRecoveryPermissionDrivesTheNeedToSetMasterPassword ) )
150- {
151- hasManageResetPasswordPermission = await EvaluateHasManageResetPasswordPermission ( ) ;
152- }
153- else
154- {
155- // TODO: PM-26065 remove use of above feature flag from the server, and remove this branching logic, which
156- // has been replaced by EvaluateHasManageResetPasswordPermission.
157- // Determine if user has manage reset password permission as post sso logic requires it for forcing users with this permission to set a MP.
158- // When removing feature flags, please also see notes and removals intended for test suite in
159- // Build_WhenManageResetPasswordPermissions_ShouldReturnHasManageResetPasswordPermissionTrue.
160-
161- // when a user is being created via JIT provisioning, they will not have any orgs so we can't assume we will have orgs here
162- if ( _currentContext . Organizations != null && _currentContext . Organizations . Any ( o => o . Id == _ssoConfig . OrganizationId ) )
163- {
164- // TDE requires single org so grabbing first org & id is fine.
165- hasManageResetPasswordPermission = await _currentContext . ManageResetPassword ( _ssoConfig ! . OrganizationId ) ;
166- }
167-
168- // If sso configuration data is not null then I know for sure that ssoConfiguration isn't null
169-
170- // NOTE: Commented from original impl because the organization user repository call has been hoisted to support
171- // branching paths through flagging.
172- //organizationUser = await _organizationUserRepository.GetByOrganizationAsync(_ssoConfig.OrganizationId, _user.Id);
173-
174- hasManageResetPasswordPermission |= organizationUser != null && ( organizationUser . Type == OrganizationUserType . Owner || organizationUser . Type == OrganizationUserType . Admin ) ;
175- }
176-
142+ var hasManageResetPasswordPermission = await EvaluateHasManageResetPasswordPermission ( ) ;
143+
177144 // They are only able to be approved by an admin if they have enrolled is reset password
178145 var hasAdminApproval = organizationUser != null && ! string . IsNullOrEmpty ( organizationUser . ResetPasswordKey ) ;
179146
0 commit comments