public async Task UnsyncUserAsync(Guid userId, Guid scimAppSettingsId) { ScimUserSyncState syncState = await _authDbContext .ScimUserSyncStates .SingleAsync(s => s.SCIMAppSettings.Id == scimAppSettingsId && s.User.Id == userId); Gatekeeper.SCIM.Client.Client scimClient = await GetScimClient(scimAppSettingsId); DeleteUserAction deleteUser = new DeleteUserAction(syncState.ServiceId); DeleteUserResult deleteUserResult = await scimClient.PerformAction <DeleteUserResult>(deleteUser); _authDbContext.Remove(syncState); await _authDbContext.SaveChangesAsync(); }
public void DeleteAuthInfo(Guid userId) { var authInfo = _authDbContext.AuthInfo.FirstOrDefault(i => i.UserId == userId); _authDbContext.Remove(authInfo); _authDbContext.SaveChanges(); }
public override async Task <RemoveAuthenticatorReply> RemoveAuthenticator(RemoveAuthenticatorRequest request, ServerCallContext context) { Guid id = new Guid(request.Id); AppUser user = await _userManager.GetUserAsync(context.GetHttpContext().User); UserTotpDevice device = await _authDbContext.UserTotpDevices .Where(d => d.User == user) .Where(d => d.Id == id) .SingleAsync(); int deviceCount = await _authDbContext.UserTotpDevices .Where(d => d.User == user) .CountAsync(); _authDbContext.Remove(device); await _authDbContext.SaveChangesAsync(); // FIXME: Should really not be in here if (deviceCount == 1) { await _userManager.SetTwoFactorEnabledAsync(user, false); } return(new RemoveAuthenticatorReply { Success = true, }); }
public async Task <bool> TryDismissUserAlertAsync(AppUser user, Guid alertId) { UserSecurityAlert?alert = await _authDbContext.UserSecurityAlerts .Where(a => a.Recipient == user) .SingleOrDefaultAsync(s => s.Id == alertId); if (alert == null) { return(false); } _authDbContext.Remove(alert); await _authDbContext.SaveChangesAsync(); return(true); }
public virtual async Task DeleteAsync(TEntity entity) { ArgumentGuard.NotNull(entity, nameof(entity)); _dbContext.Remove(entity); await _dbContext.SaveChangesAsync(); }
public RepositoryOperationResult Delete(Guid id) { var toDelete = _set.FirstOrDefault(x => x.Id == id); if (toDelete == null) { return(new RepositoryOperationResult(false, $"Entity with id {id} not exists")); } _context.Remove(toDelete); return(new RepositoryOperationResult()); }
public override async Task <DeleteGroupReply> DeleteGroup(DeleteGroupRequest request, ServerCallContext context) { UserGroup group = await _authDbContext.UserGroup .SingleAsync(g => g.Id == new Guid(request.Id)); _authDbContext.Remove(group); await _authDbContext.SaveChangesAsync(); return(new DeleteGroupReply { Success = true, }); }
public async Task <IActionResult> RemoveBookFromUser(string bookId, string appUserId) { var appUserBook = await _db.AppUserBooks.FirstAsync((row) => row.AppUserId == appUserId && row.BookId == bookId); if (appUserBook == null) { return(RedirectToAction("Index")); } _db.Remove(appUserBook); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public override async Task <DeleteAppReply> DeleteApp(DeleteAppRequest request, ServerCallContext context) { AuthApp app = await _authDbContext.AuthApp .SingleAsync(a => a.Id == new Guid(request.AppId)); _authDbContext.Remove(app); await _authDbContext.SaveChangesAsync(); // fixme: this should be done outside a service await _memoryPopulator.PopulateFromDatabase(); return(new DeleteAppReply { Success = true, }); }
public override async Task <RemoveAuthenticatorReply> RemoveAuthenticator(RemoveAuthenticatorRequest request, ServerCallContext context) { Guid id = new Guid(request.Id); AppUser user = await _userManager.GetUserAsync(context.GetHttpContext().User); UserTotpDevice device = await _authDbContext.UserTotpDevices .Where(d => d.User == user) .Where(d => d.Id == id) .SingleAsync(); _authDbContext.Remove(device); await _authDbContext.SaveChangesAsync(); return(new RemoveAuthenticatorReply { Success = true, }); }