Exemplo n.º 1
0
        /// <summary>
        /// 获取已认证的用户
        /// </summary>
        /// <returns></returns>
        public virtual AccountUser GetAuthenticatedAccountUser()
        {
            if (_cachedAccountUser != null)
            {
                return(_cachedAccountUser);
            }

            if (_httpContext == null ||
                _httpContext.Request == null ||
                !_httpContext.Request.IsAuthenticated)
            {
                return(null);
            }

            var principal = HttpContext.Current.User as ClaimsPrincipal;
            var guidClaim = principal.FindFirst(ct => ct.Type == ClaimTypes.NameIdentifier);

            if (guidClaim == null)
            {
                return(null);
            }

            var property = _customerService.GetAccountUserByGuid(new Guid(guidClaim.Value));

            if (property != null && property.Active && !property.Deleted && property.IsRegistered())
            {
                _cachedAccountUser = property;
            }
            return(_cachedAccountUser);
        }
Exemplo n.º 2
0
        public IHttpActionResult CheckFirstUser(string guid)
        {
            var account = _accountUserService.GetAccountUserByGuid(new Guid(guid));

            if (account == null || account.FirstTime)
            {
                return(Ok("true"));
            }
            else
            {
                return(Ok("false"));
            }
        }