/// <summary>
        /// 密码登录
        /// </summary>
        /// <param name="user">用户</param>
        /// <param name="password">密码</param>
        ///  <param name="isPersistent">cookie是否持久保留,设置为false,当关闭浏览器则cookie失效</param>
        /// <param name="lockoutOnFailure">达到登录失败次数是否锁定</param>
        private async Task <SignInResult> PasswordSignIn(TUser user, string password, bool isPersistent = false,
                                                         bool lockoutOnFailure = true)
        {
            var signInResult =
                await IdentitySignInManager.PasswordSignInAsync(user, password, isPersistent, lockoutOnFailure);

            if (signInResult.IsNotAllowed)
            {
                return(new SignInResult(SignInState.Failed, null, SecurityResources.UserIsDisabled));
            }
            if (signInResult.IsLockedOut)
            {
                return(new SignInResult(SignInState.Failed, null, SecurityResources.LoginFailLock));
            }
            if (signInResult.Succeeded)
            {
                return(new SignInResult(SignInState.Succeeded, user.Id.SafeString()));
            }
            if (signInResult.RequiresTwoFactor)
            {
                return(new SignInResult(SignInState.TwoFactor, user.Id.SafeString()));
            }
            return(new SignInResult(SignInState.Failed, null, SecurityResources.InvalidAccountOrPassword));
        }
 /// <summary>
 /// 退出登录
 /// </summary>
 public virtual async Task SignOutAsync() => await IdentitySignInManager.SignOutAsync();
 /// <summary>
 /// 初始化一个<see cref="SignInManager{TUser,TKey}"/>类型的实例
 /// </summary>
 /// <param name="identitySignInManager">Identity登录管理</param>
 /// <param name="userManager">用户管理</param>
 public SignInManager(IdentitySignInManager <TUser, TKey> identitySignInManager
                      , IUserManager <TUser, TKey> userManager)
 {
     IdentitySignInManager = identitySignInManager;
     UserManager           = userManager;
 }