Hello all,
I have Asp.net web Application project with WebApi and individuals user Account. I implemented Registration and login, and I used angularjs in front end.
Now, I need to store cookies in browser.
I'm confused if authentication based on cookies store cookies in browser?
In my project I authenticate users based on token.
I do research but it confuse me and I did't find a clear guide to store cookies using Asp.Net Identity webApi?
Also, I don't understand if I need to use claims?
This is the mothed for check user authentication:
- 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;
- }
- 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);
- }