public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            //return base.GrantResourceOwnerCredentials(context);
            UserMasterRepository _repo = new UserMasterRepository();

            var user = _repo.validateUser(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "Provided user name and passsword is incorrect.");
                return;
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            string[] Roles = user.UserRoles.Split(',');

            foreach (string item in Roles)
            {
                identity.AddClaim(new Claim(ClaimTypes.Role, item));
            }

            identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName));
            identity.AddClaim(new Claim("Email", user.UserEmailID));

            context.Validated(identity);
        }
 public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
 {
     using (UserMasterRepository _repo = new UserMasterRepository())
     {
         var user = _repo.ValidateUser(context.UserName, context.Password);
         if (user == null)
         {
             context.SetError("invalid_grant", "Provided username and password is incorrect");
             return;
         }
         var identity = new ClaimsIdentity(context.Options.AuthenticationType);
         identity.AddClaim(new Claim(ClaimTypes.Role, user.RoleName));
         identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName));
         identity.AddClaim(new Claim("Email", user.Email));
         context.Validated(identity);
     }
 }