Issues using SSO in custom web app

Sorry, I may have confused things a bit. The issue for us is when a user in our web app is different from the user logged into our Discourse instance. I am trying to figure out of there is a way for Discourse to recognize that an incoming user visiting from our web app is different than the currently logged-in Discourse user:

  • Two applications exist “wrapped” into a mobile hybrid app: 1. mycompany.com (i.e. our web app) and 2. forum.mycompany.com (i.e. Discourse). From a usability standpoint, both of these applications are packaged into a mobile application, which utilizes a webview, called MyCompany App…forum.mycompany.com is just a menu item called “Community”
  • John@mycompany.com is logged into the webapp (mycompany.com) and decides to click on the “Community” menu item inside of the mobile app (MyCompany App), which redirects him to forum.mycompany.com
    – Upon entering forum.mycompany.com (i.e. Discourse) inside of MyCompany App, John immediately notices that he is logged in under sarah@mycompany.com, who was using the company’s shared smartphone the day before (her session at mycompany.com had timed out and made MyComapny App appear as if nobody was authenticated on the smartphone…however, Sarah was still authenticated inside of Discourse, so when John logged in to the MyCompany App via the webapp’s webview (mycompany.com) using his credentials and attempted to navigate to the “Community” menu item (forum.mycompany.com), Sarah was still authenticated inside of Discourse).

My question is this - can we fix this issue by passing our webapp’s authenticated user via url to Discourse when mobile app users click the “Community” menu item? (ex. instead of just hyperlinking the menu item to forum.mycompany.com, we might dynamically link forum.mycompany.com/{externalID}). In this way, Discourse would be able to identify whether the user visiting from our web app (mycompany.com) is the same user as the current authenticated user inside of forum.mycompany.com. If the users’ externalID does not match, discourse can log out the current user and then redirect the browser back to mycompany.com/discourse/sso, which will then in turn authenticate the correct user back into Discourse. This issue only exists when a user’s session times out in our web app, in which case using the API to log out the user from the Discourse instance will not work.