public override void Create(AuthenticationTokenCreateContext context) { if (context.Ticket.Identity.AuthenticationType == AuthenticationType.Anonymous) { return; } //var authTicketService = ObjectFactory.GetInstance<AuthTicketService>(); var refreshToken = string.Empty; while (true) { refreshToken = GenerateRefreshToken(); if (true/*!authTicketService.Exists(x => x.Id == refreshToken)*/) { break; } } var clientId = context.Ticket.Properties.Dictionary["client_id"]; var authTicket = new AuthTicket() { RefreshToken = refreshToken, ResourceOwner = context.Ticket.Identity.FindFirst("Email").Value, ClientId = context.Ticket.Properties.Dictionary["client_id"], AccessToken = context.SerializeTicket(), Issued = context.Ticket.Properties.IssuedUtc.Value.DateTime, Expires = context.Ticket.Properties.ExpiresUtc.Value.DateTime }; //authTicketService.Create(authTicket); context.SetToken(authTicket.RefreshToken); }
public override void Receive(AuthenticationTokenReceiveContext context) { //var authTicketService = ObjectFactory.GetInstance<AuthTicketService>(); //var authTicket = authTicketService.Single(context.Token); var authTicket = new AuthTicket() { }; if (authTicket != null) { //authTicketService.Delete(authTicket); context.DeserializeTicket(authTicket.AccessToken); } }