Esempio n. 1
0
 public AuthenticationService(FriendyContext friendyContext,
                              IJwtConf jwtService,
                              IRepositoryWrapper repository,
                              IMapper mapper)
 {
     _friendyContext = friendyContext;
     _jwtService     = jwtService;
     _repository     = repository;
     _mapper         = mapper;
 }
Esempio n. 2
0
        public async Task Invoke(HttpContext context, IJwtConf jwtConf)
        {
            var token = context.Request.Cookies["SESSION_TOKEN"];

            if (token != null)
            {
                var tokenValidity = jwtConf.ValidateJwt(token.Split(" ")[1]);
                if (tokenValidity)
                {
                    var userId = jwtConf.GetUserIdFromJwt(token);
                    context.Request.Headers.Append("UserId", Convert.ToString(userId));
                }
            }

            await _next.Invoke(context);
        }