Question

Change the login button link/pop up

  • 14 September 2021
  • 4 replies
  • 104 views

My requirement is kind of simple :)

I am trying to enable OpenID connect based login for insided forum. The current behaviour is that even if OpenID connect based login is the only option available, clicking on the “Login” button opens up a popup similar to below.

 

Click on Login

 

Popup

Instead what I want is to directly take the user to my OpenID Connect identity provider when the user click on the login button.

The behaviour I expect is similar to https://community.zapier.com/ where the link on the Login Button directly takes the user to https://community.zapier.com/ssoproxy/login?ssoType=oauth2 which I assume is a similar URL the browser would take me if I select the OpenID connect option from the pop up.

I edited the login button in the browser (HTML editing) and it worked as expected. ie, I linked the button to take me to OpenID connect provider.

 

What would be the cleanest approach to do this?
Is it possible to modify the login button link directly?


TIA

 


4 replies

Badge

I’ve tried to do this too but I think I’ve missed something as nothing happens upon clicking with this script:

<script> 
var loginButton = document.getElementsByClassName("header-login-button");
loginButton[0].setAttribute('href', '/topic/new');
loginButton[0].removeAttribute('data-modal');
loginButton[0].setAttribute('class', 'header-login-button qa-header-login-button btn btn--secondary');
</script>

(Using topic/new to test...)

And yet the resulting code looks exactly the same as what is on the Zapier community login button!?!?! I’d love some input!

Userlevel 4
Badge +3

Hi @mefarazath & @SmartlyGreg :wave: ,

 

Yes we can modify the login button URL from our side, which is probably the cleanest approach. This is probably why your script isn’t working as expected @SmartlyGreg - it is getting overridden by some configuration behind the scenes.

 

If you let me know the URLs you would like this button to point to, I will happily make the change to your community’s configuration. You’re welcome to reply here or if you prefer, you can also submit a ticket to support@insided.com.

 

Thanks

@SmartlyGreg 

This is what I have currently under ‘Third Party Scripts’ → ‘Before </Body>’

<script>
// Mutator observer to check for changes in the login modal and kick of SSO flow
function callback(mutationList, observer) {
if (inSidedData.user.role === 'roles.guest') {
window.location = '/ssoproxy/login?ssoType=openidconnect&returnUrl=' + encodeURIComponent(window.location.href);
}
}

const targetNode = document.querySelector(".qa-login-modal");
const observerOptions = {
childList: true,
attributes: true,

// Omit (or set to false) to observe only changes to the parent node
//subtree: true
}

const observer = new MutationObserver(callback);
observer.observe(targetNode, observerOptions);
</script>

 

Actually this script was added by the insided support team. Based on which login type you are planning for SSO you can change the ssoType parameter.

 

 

Badge

Thanks @mefarazath that is super helpful!

Reply