Exemple #1
0
        public LogsController(IHttpContextAccessor httpContext)
        {
            var        token     = httpContext.HttpContext.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();
            JwtDecoder jwtHelper = new JwtDecoder();

            loginUser = jwtHelper.DecodeJwt(token);  // Get User Back
        }
        public UsersController(ApiContext context, IUserService userService, IMapper mapper, IHttpContextAccessor httpContext)
        {
            _context          = context;
            this._userService = userService;
            this._mapper      = mapper;

            var token = httpContext.HttpContext.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();

            if (token != null)
            {
                JwtDecoder jwtHelper = new JwtDecoder();
                loginUser = jwtHelper.DecodeJwt(token);
            }
        }
        public AdvertisementController(IAdvertisementService advertisementService,
                                       IMapper mapper,
                                       IHttpContextAccessor httpContext,
                                       ILogger <UsersController> logger)
        {
            this._advertisementService = advertisementService;
            this._mapper = mapper;
            this._logger = logger;

            var token = httpContext.HttpContext.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();

            if (token != null)
            {
                JwtDecoder jwtHelper = new JwtDecoder();
                loginUser = jwtHelper.DecodeJwt(token);
            }
        }