public AccountService(EFCoreContext _db,
                              DefaultRepository <Sys_UserRole> _dbUserRole,
                              DefaultRepository <Sys_AppLog> _dbAppLog,
                              IHttpContextAccessor iHttpContextAccessor)
            : base(_db)
        {
            this.dbUserRole  = _dbUserRole;
            this.dbAppLog    = _dbAppLog;
            this.httpContext = iHttpContextAccessor.HttpContext;

            this.Key = $"Authorization_{httpContext.Request.Host.Host}_{httpContext.Request.Host.Port}";

            //获取 cookie
            var token = this.GetToken();

            if (!string.IsNullOrWhiteSpace(token))
            {
                var Id = new JwtTokenUtil().ReadJwtToken(token).ToGuid();

                this.info = this.GetAccountByUserId(Id.ToGuid()).Result;
            }

            //if (httpContext.User != null)
            //{
            //    var claimsIdentity = httpContext.User.Identity as System.Security.Claims.ClaimsIdentity;
            //    if (claimsIdentity.Name != null)
            //    {
            //        var Id = claimsIdentity.Name;
            //        this.info = this.GetAccountByUserId(Id.ToGuid()).Result;
            //    }Toolkit.ReadXmlSummary.XMLFromName(System.Type, char, string) (位于 [ReadXmlSummary.cs] 中)(navigate-to-context
            //}
        }
Exemple #2
0
        public AccountService(AppConfiguration appConfiguration,
                              EFCoreContext _db,
                              DefaultRepository <Sys_UserRole> _dbUserRole,
                              DefaultRepository <Sys_AppLog> _dbAppLog,
                              IHttpContextAccessor iHttpContextAccessor)
            : base(_db)
        {
            this.appConfiguration = appConfiguration;
            this.dbUserRole       = _dbUserRole;
            this.dbAppLog         = _dbAppLog;
            this.httpContext      = iHttpContextAccessor.HttpContext;

            this.Key = $"Authorization_{httpContext.Request.Host.Host}_{httpContext.Request.Host.Port}";

            //获取 cookie
            var token = this.GetToken();

            if (!string.IsNullOrWhiteSpace(token))
            {
                var Id = new JwtTokenUtil().ReadJwtToken(token).ToGuid();

                this.info = this.GetAccountByUserId(Id.ToGuid()).Result;
            }

            //if (httpContext.User != null)
            //{
            //    var claimsIdentity = httpContext.User.Identity as System.Security.Claims.ClaimsIdentity;
            //    if (claimsIdentity.Name != null)
            //    {
            //        var Id = claimsIdentity.Name;
            //        this.info = this.GetAccountByUserId(Id.ToGuid()).Result;
            //    }
            //}
        }