public AuthorizeProfile GetProfile()
        {
            var context = _accessor.HttpContext;

            AuthorizeProfile authorizeProfile = null;

            var claims              = context.User.Claims;
            var userIdData          = claims.FirstOrDefault(c => c.Type == "UserId");
            var userOrgnizarionData = claims.FirstOrDefault(c => c.Type == "Organization");


            int UserId        = -1;
            int OrgnizationId = -1;

            int.TryParse(userIdData?.Value, out UserId);
            int.TryParse(userOrgnizarionData?.Value, out OrgnizationId);

            if (UserId != -1 && OrgnizationId != -1)
            {
                authorizeProfile        = new AuthorizeProfile();
                authorizeProfile.UserId = UserId;
                authorizeProfile.UserId = OrgnizationId;
            }

            return(authorizeProfile);
        }
Example #2
0
 public ValuesController(AuthorizeProfile authorizeProfile)
 {
     _authorizeProfile = authorizeProfile;
 }
Example #3
0
 public UserRepository(IUnitOfWork <AccountDbContext> unitOfWork, IMapper mapper, AuthorizeProfile authorizeProfile)
     : base(authorizeProfile)
 {
     _uow    = unitOfWork;
     _mapper = mapper;
 }
Example #4
0
 public BaseRepository(AuthorizeProfile authorizeProfile)
 {
     UserId        = authorizeProfile.UserId;
     OrgnizationId = authorizeProfile.OrgnizationId;
 }