login method
Authenticates the given username and password.
- The returned
Futureobject 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 new AuthenticationException("the cause"); -
return new 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 new AuthenticationException("Incorrect username or password");
}