public JsonResult VerifyToken(string token)
        {
            if (!HttpContext.Session.TryGetValue("userName", out var userNameBytes) || !HttpContext.Session.TryGetValue("rememberMe", out var rememberMeBytes))
            {
                return(JsonBusinessErrorResult("会话已超时,请重新登录"));
            }
            var user       = DbContext.Users.SingleOrDefault(x => x.UserName == Encoding.UTF8.GetString(userNameBytes));
            var rememberMe = Convert.ToBoolean(rememberMeBytes[0]);

            if (user == null)
            {
                return(JsonBusinessErrorResult("用户名不存在"));
            }
            if (user.IsDisabled)
            {
                return(JsonBusinessErrorResult("用户已被禁用"));
            }

            var b = GoogleAuthenticatorHelper.ValidateGoogleAuthenticatorToken(user.GoogleAuthSecretKey, token);

            if (!b)
            {
                return(JsonBusinessErrorResult("验证失败"));
            }

            SignIn(user);
            return(JsonSuccessResult(b));
        }
        public async Task <JsonResult> GetAuthenticatorUri()
        {
            if (!HttpContext.Session.TryGetValue("userName", out var userNameBytes))
            {
                return(JsonBusinessErrorResult("会话已超时,请重新登录"));
            }
            var user = DbContext.Users.SingleOrDefault(x => x.UserName == Encoding.UTF8.GetString(userNameBytes));

            if (string.IsNullOrWhiteSpace(user.GoogleAuthSecretKey))
            {
                user.GoogleAuthSecretKey = GoogleAuthenticatorHelper.GenerateNewGoogleAuthenticatorSecretKey();
                DbContext.Update(user);
                await DbContext.SaveChangesAsync();
            }

            var qrcodeUrl = GoogleAuthenticatorHelper.GetAuthenticatorUrl(user.GoogleAuthSecretKey, user.UserName, _configuration["SiteConfig:AppName"]);

            return(JsonSuccessResult(qrcodeUrl));
        }
        public void GetqrCodeImageUrlTest()
        {
            string url = GoogleAuthenticatorHelper.GetqrCodeImageUrl();

            Console.WriteLine(url);
        }