login method
Authenticates the given username and password.
The returned Future object shall carry the user object if successful.
If failed, throw an instance of AuthenticationException:
Future login(HttpConnect connect, String username, String password) async {
//...
if (failed)
throw AuthenticationException("the cause");
return User(username, roles); //any non-null object
});
Implementation
@override
Future<SimpleUser> login(HttpConnect connect, String username, String password) async {
final userInfo = _userInfos[username];
if (userInfo != null && userInfo.password == password)
return userInfo.user;
throw AuthenticationException("Incorrect username or password");
}