packages/chore/upgrade-authentication #196
@ -40,6 +40,7 @@ abstract class AuthenticationCubit<Data>
 | 
				
			|||||||
  /// {@macro authentication_cubit}
 | 
					  /// {@macro authentication_cubit}
 | 
				
			||||||
  AuthenticationCubit({
 | 
					  AuthenticationCubit({
 | 
				
			||||||
    required this.authenticationRepository,
 | 
					    required this.authenticationRepository,
 | 
				
			||||||
 | 
					    this.checkForCachedAccountOnInitialization = true,
 | 
				
			||||||
  }) : super(const AuthenticationState.unknown()) {
 | 
					  }) : super(const AuthenticationState.unknown()) {
 | 
				
			||||||
    _init();
 | 
					    _init();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -47,6 +48,9 @@ abstract class AuthenticationCubit<Data>
 | 
				
			|||||||
  /// The authentication repository.
 | 
					  /// The authentication repository.
 | 
				
			||||||
  final AuthenticationRepository<Data> authenticationRepository;
 | 
					  final AuthenticationRepository<Data> authenticationRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Automatically check for cached account on initialization.
 | 
				
			||||||
 | 
					  final bool checkForCachedAccountOnInitialization;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// The latest session.
 | 
					  /// The latest session.
 | 
				
			||||||
  AuthenticationSession<Data>? _latestSession;
 | 
					  AuthenticationSession<Data>? _latestSession;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -56,7 +60,9 @@ abstract class AuthenticationCubit<Data>
 | 
				
			|||||||
    _listenForAuthenticationChanges();
 | 
					    _listenForAuthenticationChanges();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Check if there is a cached account.
 | 
					    /// Check if there is a cached account.
 | 
				
			||||||
    await authenticationRepository.checkForCachedAccount();
 | 
					    if (checkForCachedAccountOnInitialization) {
 | 
				
			||||||
 | 
					      await checkForCachedAccount();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void _listenForAuthenticationChanges() {
 | 
					  void _listenForAuthenticationChanges() {
 | 
				
			||||||
@ -148,6 +154,10 @@ abstract class AuthenticationCubit<Data>
 | 
				
			|||||||
        ),
 | 
					        ),
 | 
				
			||||||
      ).call();
 | 
					      ).call();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Checks for cached account.
 | 
				
			||||||
 | 
					  FutureOr<void> checkForCachedAccount() async =>
 | 
				
			||||||
 | 
					      authenticationRepository.checkForCachedAccount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Returns latest session.
 | 
					  /// Returns latest session.
 | 
				
			||||||
  ///
 | 
					  ///
 | 
				
			||||||
  /// Contains latest event and latest session data (account + extra data)
 | 
					  /// Contains latest event and latest session data (account + extra data)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user