mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 17:12:49 -05:00
EC-262 - implement org user deactivated flag and behavior server (#2050)
* SM-47 - Add Disabled status to enum + schema * SM-47 - Enable and disable sprocs and repositories * SM-47 - Organization service enble/disable user * SM-47 - Fix lint errors * SM-47 - add disable/enable endpoints to API * SM-47 - Add bulk operations for enable/disable * SM-47 - Fix linting errors, one of these days I'll do this first * SM-47 - Codesense fix DRY warnings * EC-262 - Code review changes, async cleanup * EC-262 - Fix build issues, async refs * EC-262 - Update controller param types * EC-262 - Ensure mutable state is correct * EC-262 - rename disabled to deactivated
This commit is contained in:
@ -427,5 +427,43 @@ namespace Bit.Infrastructure.EntityFramework.Repositories
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeactivateAsync(Guid id)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var orgUser = await GetDbSet(dbContext).FindAsync(id);
|
||||
if (orgUser != null)
|
||||
{
|
||||
dbContext.Update(orgUser);
|
||||
orgUser.Status = OrganizationUserStatusType.Deactivated;
|
||||
await dbContext.SaveChangesAsync();
|
||||
if (orgUser.UserId.HasValue)
|
||||
{
|
||||
await UserBumpAccountRevisionDate(orgUser.UserId.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ActivateAsync(Guid id, OrganizationUserStatusType status)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var orgUser = await GetDbSet(dbContext).FindAsync(id);
|
||||
if (orgUser != null)
|
||||
{
|
||||
dbContext.Update(orgUser);
|
||||
orgUser.Status = status;
|
||||
await dbContext.SaveChangesAsync();
|
||||
if (orgUser.UserId.HasValue)
|
||||
{
|
||||
await UserBumpAccountRevisionDate(orgUser.UserId.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user