public async Task <IActionResult> Get(string t = "")
        {
            // _logger.LogError("Error Log");
            // throw new Exception("error");
            //await userService.RegisterTestUser();
            string xsrfToken   = "";
            string accessToken = "";

            if (User.Identity.IsAuthenticated)
            {
                var appUser = await userService.FindById(User.Identity.Name);

                var roles = await userService.GetUserRoles(appUser);

                var token = await _tokenService.createAccessTokenAsync(appUser, roles.ToList());

                accessToken = token.AccessToken;
                xsrfToken   = _antiforgery.RegenerateAntiForgeryCookies(new ClaimsPrincipal(new ClaimsIdentity(token.claims, JwtBearerDefaults.AuthenticationScheme)));
            }
            return(Json(new { Config = _apiSettingsConfig.Value, Xsrftoken = xsrfToken, AccessToken = accessToken }));
        }
        public async Task <IActionResult> login([FromBody] LoginModel user)
        {
            try
            {
                await _userService.Logout();

                _antiforgery.DeleteAntiForgeryCookies();

                var result = await _userService.Authenticate(user.Username, user.Password, user.RememberMe);

                if (result.Succeeded)
                {
                    var appUser = await _userService.FindById(user.Username);

                    var roles = await _userService.GetUserRoles(appUser);

                    var token = await _tokenService.createAccessTokenAsync(appUser, roles.ToList());

                    var Menus = (await _userService.GetMenus(appUser)).ToList();
                    if (!Menus.Any())
                    {
                        Menus.Add(new Model.DbSets.Menu.Menu()
                        {
                            Id        = 1,
                            Name      = "خانه",
                            Route     = "",
                            IsVisible = true
                        });
                    }

                    string xsrfToken = _antiforgery.RegenerateAntiForgeryCookies(new ClaimsPrincipal(new ClaimsIdentity(token.claims, JwtBearerDefaults.AuthenticationScheme)));
                    return(Json(
                               new HttpResult()
                    {
                        Success = true,
                        Message = "",
                        Data = new UserViewMolel()
                        {
                            Menus = Menus,
                            Email = appUser.Email,
                            Roles = roles.ToList(),
                            ImageLink = appUser.ImageLink,
                            OrgId = appUser.OrgId,
                            XsrfToken = xsrfToken,
                            UserId = appUser.Id,
                            NationalCode = appUser.NationalCode,
                            Firstname = appUser.Firstname,
                            LastName = appUser.LastName,
                            UserName = appUser.UserName,
                            PhoneNumber = appUser.PhoneNumber,
                            Access_token = token.AccessToken     //GenerateJwtToken(user.username, appUser,claims.Claims.ToList())
                        }
                    }));
                }
                else if (result.IsLockedOut)
                {
                    return(Json(new HttpResult()
                    {
                        Success = false,
                        Message = "کاربری شما قفل شده"
                    }));
                }
                else
                {
                    return(Json(new HttpResult()
                    {
                        Success = false,
                        Message = "نام کاربری یا رمز عبور اشتباه است"
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new HttpResult()
                {
                    Success = false,
                    Message = "مشکلی در انجام عملیات وجود دارد"
                }));
            }
        }