protected override System.Threading.Tasks.Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { if (request.RequestUri.ToString().Contains("api/auth")) { return(base.SendAsync(request, cancellationToken)); } IEnumerable <string> sampleApiKeyHeaderValues = null; if (request.Headers.TryGetValues("authToken", out sampleApiKeyHeaderValues)) { string[] apiKeyHeaderValue = sampleApiKeyHeaderValues.First().Split(':'); if (apiKeyHeaderValue.Length == 2) { if (!int.TryParse(apiKeyHeaderValue[0], out int userId)) { return(requestCancel(request, cancellationToken, InvalidToken)); } var accessToken = apiKeyHeaderValue[1]; string realAccessToken; using (var db = new WorkItDbContext()) { realAccessToken = db.Users.FirstOrDefault(u => u.UserId == userId).AccessToken; } if (realAccessToken == accessToken) { return(base.SendAsync(request, cancellationToken)); } else { return(requestCancel(request, cancellationToken, InvalidToken)); } } else { return(requestCancel(request, cancellationToken, MissingToken)); } } else { return(requestCancel(request, cancellationToken, MissingToken)); } }
public RaitingBussinessLogic(WorkItDbContext db) { this.Db = db; }
public UserBussinessLogic(WorkItDbContext db) { this.Db = db; }
public DialogBussinessLogic(WorkItDbContext db) { this.Db = db; }
public TaskRequestBussinessLogic(WorkItDbContext db) { this.Db = db; }
public MessagesBussinessLogic(WorkItDbContext db) { this.Db = db; }