private AuthenticateResult Authenticate() { ETSContext _DBContext = new ETSContext(Cache, Db); string token = Context.Request.Headers["X-Authorized-Header"]; int ModuleID = 1; if (token == null || ModuleID == 0) { return(AuthenticateResult.Fail("No Authorization provided")); } try { validateSecurityToken(token, ModuleID); var claims = new[] { new Claim(ClaimTypes.Name, token) }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); var ticket = new AuthenticationTicket(principal, Scheme.Name); return(AuthenticateResult.Success(ticket)); } catch (Exception ex) { return(AuthenticateResult.Fail("Failed to validate token")); } }
/// <summary> /// Initializes a new instance of the <see cref="IRepository{T}"/> class. /// </summary> /// <param name="context"></param> public RepositoryService(ETSContext context) { this.dbContext = context; }