Exemplo n.º 1
0
        public async Task IsActiveAsync(IsActiveContext context)
        {
            var sub = context.Subject?.GetSubjectId();

            if (sub == null)
            {
                throw new Exception("No subject Id claim present");
            }

            var userId = ConvertUtil.ConvertToInt(sub);

            if (userId > 0)
            {
                var user = await _userService.FindById(userId);

                if (user == null)
                {
                    //_loggerService.Debug($"No user found matching subject Id: {sub}");
                }

                context.IsActive = user != null;
            }
            else
            {
                context.IsActive = false;
            }
        }
Exemplo n.º 2
0
        public async Task GetProfileDataAsync(ProfileDataRequestContext context)
        {
            try
            {
                var sub = context.Subject.GetSubjectId();
                if (!string.IsNullOrEmpty(sub))
                {
                    var userId = ConvertUtil.ConvertToInt(sub);
                    if (userId > 0)
                    {
                        var user = await _userService.FindById(userId);

                        if (user != null)
                        {
                            var claims = await _userService.GetClaims(userId);

                            if (claims != null)
                            {
                                context.AddRequestedClaims(claims.Data);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                //
            }
        }