Extending header buttons

Hi - we have inherited a Discourse forum which is well established. I would like to modify the functionality of the “create account” header button.

I managed to install the Ember Chrome plug-in which I used to inspect the buttons - it revealed a path:

​/​var​/​www​/​discourse​/​app​/​assets​/​javascripts​/​discourse​/​node_modules​/​.embroider​/​rewritten-app​/​components​/​header​/​auth-buttons.js

I’m not sure if but I think that the related js is here?

I have access to the admin panel of the forum, I can drill down on ‘Components’ but I don’t see an entry for these buttons. I did see some used “test” components, I tried enabling one of these and copying the contents of auth-buttons.gjs file into the common head section but when I try to save I got errors.

So my question being - how can I extend and customise the functionality of these buttons.

Thanks in advance.

Hi there, what are you trying to do with these buttons?

We want users to register via our main site - the account login then work for the forum…

You really need to use SSO. Discourse will automatically adapt to your sso provider once it is configured correctly.

5 Likes

We are already using SSO - the forum authenticates users via the same provider as our main site. However when a user register for an account at the forum we simply want to direct them to the main site - what is the best way of doing this?

Are you totally sure you really want to do that? From users’ point of view someone is trying to screw them. They were interested in a forum and after registration they’ll find themselves somewhere else.

1 Like

Disable all other methods of authentication (including local logins) only let sso remain as the option to log in. That would automatically send users to log in to your main site.

4 Likes

If you set it up properly I believe it will redirect back after sign in?

Authenticatin works - it is the “signup” button that we want to customise to go to the main site…

That’s what I suggested above.

2 Likes

I can second. If properly set up, the out of the box login and sign up buttons will go to the main site. You do not need to mess with the default UI.

1 Like

so there should be an option somewhere in the admin where I can specify the external url for the sign-up process?

No, Those parameters are supplied by your SSO provider. Discourse will only show “log in” button in header and send the user to your authentication endpoint provided by SSO provider.

Big if… I’ve seen similar solutions too often. Main purposes is then transfer an user permanently back to main site where selling happends. But totally nice if the purpose is similar than what i.e. Google does, where is taken short sidestep to authorize and then will come back to forum.

1 Like

Hello :wave:

Here is a theme component with you can add a custom Sign Up button. I’ve just updated now to work with new core changes.

So if local logins are disabled the button would go straight to the sso auth?

Yes. That’s what happens if SSO is the only auth method.

1 Like

Right, so if SSO is only concerned with Auth how will it help here when I need “create account” to go to my main site?

There won’t be a signup button once SSO is configured correctly. Then you can use the component that @Don linked above to add a custom create account button.