Verify if user is already logged (SSO with Saml2 + Discourse-Saml)

Hello everyone,

We successfully implemented the SAML2 authentication using Discourse-SAML plugin. It works great when you click in the “with SAML” button in the login page. Now, we want that if the user is already logged in our IAM (Gluu Server), it automatically authenticates the user in discourse. We want the same functionality that the “with SAML” button has but just after the page load so that the user don’t need to click in the button if he is already logged in. What is the best way to achieve that? I was thinking of verifying that with javascript + JQuery.