public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); UserService _user = new UserService(); User user = _user.CheckUser(new UserAuthModel {UserName = context.UserName,Password = context.Password}); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", context.UserName)); identity.AddClaim(new Claim("role", "user")); context.Validated(identity); }
public accountUniTest() { System.Data.Entity.Database.SetInitializer<MyDbContext>(new DropCreateDatabaseIfModelChanges<MyDbContext>()); _UserService = new UserService(); }
public AccountController() { _UserService = new UserService(); }