public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var identity = new ClaimsIdentity(context.Options.AuthenticationType); var email = context.UserName; var password = context.Password; UserDto user = UserBl.ValidateUser(email, password); if (user != null) { identity.AddClaim(new Claim(ClaimTypes.Role, "user")); identity.AddClaim(new Claim("username", user.email)); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.userId.ToString())); context.Validated(identity); } else { context.SetError("invalid_grant", "אימייל או סיסמה שגויים"); return; } }