@@ -134,7 +134,8 @@ public async Task<OperationResult> UpdateUser(UserRegisterModel userRegisterMode
134134 _localizationService . GetString ( "UserNotFoundUserName" , userRegisterModel . UserName ) ) ;
135135 }
136136
137- if ( ! _dbContext . SecurityGroups . Any ( x => x . Id == userRegisterModel . GroupId ) )
137+ var isAdmin = await _userManager . IsInRoleAsync ( user , EformRole . Admin ) ;
138+ if ( ! _dbContext . SecurityGroups . Any ( x => x . Id == userRegisterModel . GroupId ) && ! isAdmin )
138139 {
139140 return new OperationResult ( false ,
140141 _localizationService . GetString ( "SecurityGroupNotFound" ) ) ;
@@ -145,8 +146,7 @@ public async Task<OperationResult> UpdateUser(UserRegisterModel userRegisterMode
145146 return new OperationResult ( false , _localizationService . GetString ( "RoleIsRequired" ) ) ;
146147 }
147148
148- if ( await _userManager . IsInRoleAsync ( user , EformRole . Admin )
149- && _userService . Role != EformRole . Admin )
149+ if ( isAdmin && _userService . Role != EformRole . Admin )
150150 {
151151 return new OperationResult ( false , _localizationService . GetString ( "YouCantViewChangeOrDeleteAdmin" ) ) ;
152152 }
@@ -297,10 +297,7 @@ public async Task<OperationResult> EnableTwoFactorAuthForce()
297297 {
298298 try
299299 {
300- await _appSettings . UpdateDb ( ( options ) =>
301- {
302- options . IsTwoFactorForced = true ;
303- } , _dbContext ) ;
300+ await _appSettings . UpdateDb ( ( options ) => { options . IsTwoFactorForced = true ; } , _dbContext ) ;
304301 }
305302 catch ( Exception )
306303 {
@@ -314,10 +311,7 @@ public async Task<OperationResult> DisableTwoFactorAuthForce()
314311 {
315312 try
316313 {
317- await _appSettings . UpdateDb ( ( options ) =>
318- {
319- options . IsTwoFactorForced = false ;
320- } , _dbContext ) ;
314+ await _appSettings . UpdateDb ( ( options ) => { options . IsTwoFactorForced = false ; } , _dbContext ) ;
321315 }
322316 catch ( Exception )
323317 {
0 commit comments