public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            AuthRepository repo = new AuthRepository();

            IdentityUser user = await repo.FindUser(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect.");
                return;
            }

            ClaimsIdentity identity = await repo.GenerateUserIdentityAsync(user, context.Options.AuthenticationType);

            context.Validated(identity);

        }
Esempio n. 2
0
 public UserBusiness()
 {
     authRepo = new AuthRepository();
 }