Can't authenticate non-admin users
Hi there, I am trying to authenticate my users but i can't. It shows always : WordPress Error! code: wp_empty_list, message: No users found, status: null
My code
Future signIn (String name, String password) async {
wp.WordPress wordPress = wp.WordPress(
baseUrl: config.websiteUrl,
authenticator: wp.WordPressAuthenticator.JWT,
adminKey: '',
adminName: '');
final response = wordPress.authenticateUser(
username: '******', password: '********');
response.then((user) async{await wordPress.authenticateUser(username: name, password: password).then((p) {
print("Success : $p");
}).catchError((e) {
print('error : $e');
});
}).catchError((e) {
});
}
Hey! I don't know if this can be useful but have a look at #38. Basically what is happening is that the authenticateUser function calls fetch user after jwt authentication which in turns what it does is to search for an specific user in WordPress rather than doing the authentication with the user, your problem might be happening because on your WordPress installation you have your admin role outside of the users that the public REST api can fetch. I'm working in a fix for this and submit a pr as soon as I'm done as my app needs to handle properly user registration before launch.
Do something, go to postman, (download it from here if you don't have it) and make a GET request as follows, check if the problem is with your WordPress installation or if the problem is with this library, replace the parenthesis with your data: https://(myWordpressWebsite)/wp-json/wp/v2/users/?search=([email protected])&

Hi there, I am trying to authenticate my users but i can't. It shows always : WordPress Error! code: wp_empty_list, message: No users found, status: null
My code
Future signIn (String name, String password) async { wp.WordPress wordPress = wp.WordPress( baseUrl: config.websiteUrl, authenticator: wp.WordPressAuthenticator.JWT, adminKey: '', adminName: ''); final response = wordPress.authenticateUser( username: '******', password: '********'); response.then((user) async{await wordPress.authenticateUser(username: name, password: password).then((p) { print("Success : $p"); }).catchError((e) { print('error : $e'); }); }).catchError((e) { }); }
Rakib I have found a solution, the main culprit is the default behaviour of WordPress itself, implementing authentication in WordPress is not that easy, as you require a specific setup to make it happen, there's a bit of refactoring needed for this library to handle incorrect login credentials, I tried to find a way to handle incorrect login credentials with the current version of the library "as is" but it needs refactoring, I don't know if this is too late for you, but if you are in a hurry and need to release something important you might have to handle for now authentication by doing manual http requests.