public static TLockoutTime?SetLockoutEnd <TLockoutTime>(this ILockout <TLockoutTime> lockout, Func <TLockoutTime?, TLockoutTime?> newLockoutFactory) where TLockoutTime : struct { lockout.NotNull(nameof(lockout)); newLockoutFactory.NotNull(nameof(newLockoutFactory)); return(lockout.LockoutEnd = newLockoutFactory.Invoke(lockout.LockoutEnd)); }
/// <summary> /// 异步设置锁定期结束时间。 /// </summary> /// <typeparam name="TLockoutTime">指定的锁定期时间类型(提供对 <see cref="DateTime"/> 或 <see cref="DateTimeOffset"/> 的支持)。</typeparam> /// <param name="lockout">给定的 <see cref="ILockout{TLockoutTime}"/>。</param> /// <param name="newLockoutFactory">给定的新 <typeparamref name="TLockoutTime"/> 工厂方法。</param> /// <param name="cancellationToken">给定的 <see cref="CancellationToken"/>(可选)。</param> /// <returns>返回一个包含锁定期结束时间(提供对 <see cref="DateTime"/> 或 <see cref="DateTimeOffset"/> 的支持)的异步操作。</returns> public static ValueTask <TLockoutTime?> SetLockoutEndAsync <TLockoutTime>(this ILockout <TLockoutTime> lockout, Func <TLockoutTime?, TLockoutTime?> newLockoutFactory, CancellationToken cancellationToken = default) where TLockoutTime : struct { lockout.NotNull(nameof(lockout)); newLockoutFactory.NotNull(nameof(newLockoutFactory)); return(cancellationToken.RunOrCancelValueAsync(() => lockout.LockoutEnd = newLockoutFactory.Invoke(lockout.LockoutEnd))); }
protected bool IsLocked(ILockout lockout) { if (lockout.LockOut >= 3) { if (lockout.LockExpire.AddMinutes(15) > DateTime.Now) { ThrowException($"Account has been locked please try again later"); } } return(false); }
private void Unlock(ILockout lockout) => Sql.AlterDataQuery("call unlockaccount(@Id)", lockout);
private void FailedAuthentication(ILockout lockout) => Sql.AlterDataQuery <ILockout>("call failduserauth(@Id)", lockout);
private void Unlock(ILockout lockout) => Sql.AlterDataQuery("call unlocktoken(@Id)", lockout);
protected void FailedAuthentication(ILockout lockout) => Sql.AlterDataQuery <ILockout>("call faildtokenauth(@Id)", lockout);
/// <summary> /// 异步设置锁定期结束时间。 /// </summary> /// <typeparam name="TLockoutTime">指定的锁定期时间类型(提供对 <see cref="DateTime"/> 或 <see cref="DateTimeOffset"/> 的支持)。</typeparam> /// <param name="lockout">给定的 <see cref="ILockout{TLockoutTime}"/>。</param> /// <param name="newLockoutFactory">给定的新 <typeparamref name="TLockoutTime"/> 工厂方法。</param> /// <param name="cancellationToken">给定的 <see cref="CancellationToken"/>(可选)。</param> /// <returns>返回一个包含锁定期结束时间(提供对 <see cref="DateTime"/> 或 <see cref="DateTimeOffset"/> 的支持)的异步操作。</returns> public static ValueTask <TLockoutTime?> SetLockoutEndAsync <TLockoutTime>(this ILockout <TLockoutTime> lockout, Func <TLockoutTime?, TLockoutTime?> newLockoutFactory, CancellationToken cancellationToken = default) where TLockoutTime : struct => cancellationToken.RunValueTask(() => lockout.LockoutEnd = newLockoutFactory(lockout.LockoutEnd));
/// <summary> /// 设置锁定期结束时间。 /// </summary> /// <typeparam name="TLockoutTime">指定的锁定期时间类型(提供对 <see cref="DateTime"/> 或 <see cref="DateTimeOffset"/> 的支持)。</typeparam> /// <param name="lockout">给定的 <see cref="ILockout{TLockoutTime}"/>。</param> /// <param name="newLockoutFactory">给定的新 <typeparamref name="TLockoutTime"/> 工厂方法。</param> /// <returns>返回一个包含锁定期结束时间(提供对 <see cref="DateTime"/> 或 <see cref="DateTimeOffset"/> 的支持)的异步操作。</returns> public static TLockoutTime?SetLockoutEnd <TLockoutTime>(this ILockout <TLockoutTime> lockout, Func <TLockoutTime?, TLockoutTime?> newLockoutFactory) where TLockoutTime : struct => lockout.LockoutEnd = newLockoutFactory(lockout.LockoutEnd);