From e3399bb708c8c01d40af48fb41089c586dd58a46 Mon Sep 17 00:00:00 2001 From: Jordan Nelson Date: Sat, 10 Jun 2023 10:45:08 -0400 Subject: [PATCH] fix(authenticator): use getCurrentUser to check sign in state --- .../lib/src/services/amplify_auth_service.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/services/amplify_auth_service.dart b/packages/authenticator/amplify_authenticator/lib/src/services/amplify_auth_service.dart index da2c66b56c..9e8a80d2c5 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/services/amplify_auth_service.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/services/amplify_auth_service.dart @@ -28,8 +28,18 @@ abstract class AuthService { Future get currentUser; + /// Checks to see if a user has a valid session. + /// + /// A valid session is a session in which the tokens are not expired, OR + /// the access/id tokens have expired but the state of the refresh token is + /// unknown due to network unavailability. Future isValidSession(); + /// Checks if a user is logged in based on whether or not there are + /// tokens on the device. + /// + /// This will not check whether or not those tokens are valid. To check + /// if tokens are valid, see [isValidSession]. Future get isLoggedIn; Future resetPassword(String username); @@ -191,9 +201,8 @@ class AmplifyAuthService Future get isLoggedIn async { return _withUserAgent(() async { try { - final result = await Amplify.Auth.fetchAuthSession(); - - return result.isSignedIn; + await Amplify.Auth.getCurrentUser(); + return true; } on SignedOutException { return false; }