Skip to content

Pass HttpContextAccessor httpContextAccessor to manager #54

@EvilLord666

Description

@EvilLord666

All manager classes should receive IHttpContextAccessor that could be used as follows:

public static class UserService
    {
        public static Guid GetCurrentUserId(IHttpContextAccessor accessor)
        {
            Claim claim = accessor.HttpContext.User.Claims.FirstOrDefault(c => c.Type == "id");
            if (claim == null)
            {
                string msg = "Authorization server does not contains \"id\" property in UserInfo, ensure that you properly configured your UserProperty Mapper";
                throw new InvalidOperationException(msg);
            }

            return Guid.Parse(claim.Value);
        }
    }

Metadata

Metadata

Assignees

Labels

Managermanager as entry to some logic around persistent objectsSecurity
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions