furaiev / amazon-cognito-identity-dart-2

Unofficial Amazon Cognito Identity Provider Dart SDK, to easily add user sign-up and sign-in to your mobile and web apps with AWS.
MIT License
187 stars 114 forks source link

auto load user (restore last session) #152

Closed subzero911 closed 3 years ago

subzero911 commented 3 years ago

On app startup I try to restore previous session, calling Auth()..load(). That's how I do it (I followed an example):

  final userPool = CognitoUserPool(
    'eu-central-1_xxx',
    'yyyzzz',
  );

void load() {
_cognitoUser = await userPool.getCurrentUser();
_session = await _cognitoUser.getSession();
}

For some reason, getCurrentUser() doesn't found a previous user on local storage image I found with debugger, that lastAuthUser is null.