public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var userManager = context.OwinContext.GetUserManager<ApplicationUserManager>(); ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } /* I tried the following but I get an error that Request doesn't exist var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, context.UserName)); var id = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); var ctx = Request.GetOwinContext(); var authenticationManager = ctx.Authentication; authenticationManager.SignIn(id); */ ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager); ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager); AuthenticationProperties properties = CreateProperties(user.UserName); AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); context.Validated(ticket); context.Request.Context.Authentication.SignIn(cookiesIdentity); }
Microsoft.Owin.Host.SystemWeb
HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)