#pragma warning restore CS0649 // Field 'UsersController.db' is never assigned to, and will always have its default value null public UsersController() { var db = new TextiplyDataContext(); var store = new UserStore <User>(db); _userManager = new UserManager <User>(store); }
#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) #pragma warning restore CS1998 // This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); var db = new TextiplyDataContext(); var store = new UserStore <User>(db); using (var manager = new UserManager <User>(store)) { var user = manager.Find(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "Incorrect username or password"); return; } } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); identity.AddClaim(new Claim(ClaimTypes.Role, "user")); context.Validated(identity); }