How can I implement separate login and registration flows for individual users and organizations in my SwiftUI iOS app?

I’m working on an iOS app using SwiftUI and Firebase for user authentication. I have two types of users: individual users and organizations. I want to implement separate login and registration flows for each user type. Currently, I have a SessionService that handles login/logout for individual users, and I’ve added an orgSessionService for organizations. However, I’m facing difficulties in integrating the registration flow for organizations and ensuring that the correct home view is displayed based on the user type. Here’s an overview of my current implementation:

  • UserAccountManagementApp sets up the Firebase configuration and manages the sessionService and orgSessionService .
  • ContentView checks the login status of individual users using sessionService.state and displays the appropriate view.
  • I have implemented the OrgRegisterView for organization registration but need help connecting it to the correct session and ensuring the correct home view is displayed.

Could someone provide guidance on how to properly handle the registration flow for organizations, including the integration with the orgSessionService , and ensure that the correct home view is displayed based on the user type? Any code examples or step-by-step explanations would be greatly appreciated. Thank you in advance for your help!

Here is the link to the project files: UserAccountManagement.xcodeproj - Google Drive