/// <summary> /// Marks the user as locked out in the store, and updates the security stamp so they are logged out. /// </summary> public static async Task LockOutAsync(this UserManager <AppUser> userManager, AppUser user, bool shouldBeLockedOut) { ThrowIf.Null(userManager, nameof(userManager)); ThrowIf.Null(user, nameof(user)); if (user.IsLockedOut == shouldBeLockedOut) { return; } var lockoutEndDate = shouldBeLockedOut ? DateTimeOffset.MaxValue : default(DateTimeOffset?); await userManager.SetLockoutEndDateAsync(user, lockoutEndDate).ConfigureAwait(false); await userManager.UpdateSecurityStampAsync(user).ConfigureAwait(false); await userManager.UpdateAsync(user).ConfigureAwait(false); }
public static T[] ArrayFromDequeuing <T>(T firstItem, ConcurrentQueue <T> nextItems) { ThrowIf.Null(nextItems, nameof(nextItems)); var arr = new T[1 + nextItems.Count]; arr[0] = firstItem; int i = 1; while (nextItems.TryDequeue(out var nextItem)) { arr[i] = nextItem; i += 1; } return(arr); }
public static string GetErrorsDebugString(this IdentityResult identityResult) { ThrowIf.Null(identityResult, nameof(identityResult)); return(string.Join(Environment.NewLine, identityResult.Errors.Select(error => $"{error.Code}: {error.Description}"))); }
public AsyncActionDisposable(Func <Task> action) { ThrowIf.Null(action, nameof(action)); _action = action; }
public ActionDisposable(Action action) { ThrowIf.Null(action, nameof(action)); _action = action; }