handleInitialize method
Initializes authentication by checking for saved sessions.
This method should be called when the app starts. It checks local storage for a previously saved authentication session and automatically restores it if found. If no saved session exists, it transitions to the initial login state.
Example:
authBloc.handleInitialize();
Implementation
Future<void> handleInitialize() async {
add(const AuthenticationProcessingEvent(AuthenticationAction.initialize));
final authentication = await authRepo.loadAuthentication();
if (authentication != null) {
add(UsingSavedAuthenticationEvent(
tenant: authentication.tenant,
user: authentication.appUser,
));
return;
}
add(AuthenticationInitializeEvent());
}