login method

  1. @override
Future<SimpleUser> login(
  1. HttpConnect connect,
  2. String username,
  3. String password
)
override

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 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");
}