public AuthenticationService(FriendyContext friendyContext, IJwtConf jwtService, IRepositoryWrapper repository, IMapper mapper) { _friendyContext = friendyContext; _jwtService = jwtService; _repository = repository; _mapper = mapper; }
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); }