public void ValidateUserNameAndPasswordPassingTest() { var users = IdentityServerDBHelper.ValidateUserNameAndPassword(ConnectionConst.CORRECTCONNECTIONSTRING, "PersonalMovieDBUI", "PersonalMovieDBUI00..").Result; Assert.NotNull(users); }
public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context) { try { var usersFromDB = await IdentityServerDBHelper.ValidateUserNameAndPassword( Startup.Configuration.GetSection("ConnectionString").Value, context.UserName, context.Password); if (usersFromDB != null && usersFromDB.Count != 0) { context.Result = new GrantValidationResult( usersFromDB[0].userSubject, authenticationMethod: "password"); } else { context.Result = new GrantValidationResult( TokenRequestErrors.InvalidGrant, "Invalid User Credential"); } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); context.Result = new GrantValidationResult( TokenRequestErrors.InvalidGrant, "Invalid User Credential"); } }