Synchronising log out of discourse when logging out of WordPress


(Nick Putman) #1

Hi,

I am using the Wordpress plugin for discourse, and I am wondering if there is a way of synchronising the logouts, as well as the logging in, to make things simpler for users.

At present, as I understand it, once users are logged in to the Wordpress site they can then navigate to the discourse forum, but have to click Login again - it would be simpler if this wasn’t necessary.

Also, it seems that logging out of either Wordpress or discourse doesn’t also log the user out of the other account. Would it be possible to implement this?

Thanks,

Nick


(Simon Cossar) #2

This should only be the case if Redirect Without Login is enabled in the plugin’s settings. Can you double check that?

This is coming. I’ll try to update the plugin for it later today.


(Nick Putman) #3

No, that setting is not enabled. I login to Wordpress, then follow a link to discourse, and I see this in discourse:

I have to click Log In on discourse, and then I’m automatically logged in:

But I’d rather my users didn’t have to take this extra step. Are you saying that they shouldn’t have to? I am not following a link to the discourse comments - I am just following a link to the home page of discourse. Not sure if this makes a difference.

Glad to hear that the synched logout is in the works!


(Simon Cossar) #4

Are you using any plugins on your WordPress site that could affect the login process? For example, a plugin that adds a captcha to the login form?


(Nick Putman) #5

I am using the Social Login plugin.


(Simon Cossar) #6

If possible, could you try disabling the plugin and see if that makes a difference?


(Nick Putman) #7

I deactivated the plugin, but see the same behaviour.


(Simon Cossar) #8

The link from your homepage to your forum doesn’t have any SSO login information associated with it. At this point SSO login only works from Discourse topics. I’ve been meaning to add some WordPress shortcodes either to the wp-discourse plugin, or to a separate plugin that will do what you are looking for.


(Nick Putman) #9

OK. Do you mean that when I click the ‘Start Discussion’ link below a blog post, this should carry the SSO login information over, as when I tried this as well, I still wasn’t logged in to discourse.


(Simon Cossar) #10

Yes that should work, but the link should be structured something like this:

<a href="http://forum.yourdomain.com/session/sso?return_path=http://forum.yourdomain.com/t/my-latest-blog-post/78">Start the discussion</a>

The links I see on your site are just pointing directly at your forum. What theme are you using? I can look at this more later today.

Edit:

I tried using my browser’s dev tools to edit the link to your forum that is on this page: Open dialogues in the present and the future – new developments | Open Dialogue by changing it to:

<a class="button" target="_blank" href="http://forum.open-dialogue.net/session/sso?return_path=http://forum.open-dialogue.net/t/open-dialogues-in-the-present-and-the-future-new-developments-jaakko-seikkula/15">Start Discussion</a>

the sso login works as expected. The thing to do is to figure out why the link is being returned in the form that it is. I would expect the wp-discourse plugin to be returning it with a similar structure to the way I have edited it.


(Nick Putman) #11

The link I am referring to is at the bottom of this blog post: Open dialogues in the present and the future – new developments | Open Dialogue

The ‘Start Discussion’ link looks like this:

So not in the same format as your link.

I am using the X theme, with a child theme


(Simon Cossar) #12

For some reason the Discourse comments are in an iframe on your site. Whatever the problem is, it seems that it’s related to the theme.


(Simon Cossar) #13

In the latest release (0.9.6) logging out is now synced between WordPress and Discourse.


(Nick Putman) #14

I was mixing methods - using a combination of the embed method described here: Embedding Discourse Comments via Javascript

and the plugin. I have sent you a PM about this.

And I have tested the synchronised log out - it works when logging out of WordPress first, but not when logging out of discourse first. Is this the expected behaviour? Ideally I would like it to work both ways.

Thanks!


(Coin-coin le Canapin) #15

Hi there. I’m using Wordpress as an SSO client.
When I log out from Discourse, it logs me out from Wordpress thanks to the logout redirect parameter.
But when logging out of Wordpress, it doesn’t log out from Discourse. How can I achieve that?


(Simon Cossar) #16

I can add it as an option to the SSO Client settings. When WordPress is used as the SSO Provider, logging out from WordPress logs the user out of Discourse. With a slight modification, that same code will work for when WordPress is the SSO Client.


(Coin-coin le Canapin) #17

That would be awesome!
While I’m asking stuff here, Is there any way to automatically log in users on WP when they log in from Discourse?


(Simon Cossar) #18

The easiest way to do that is to embed an SSO login link on your forum. You can get the format required for the link by viewing the page source code for the Login with Discourse link on your WordPress login page. You can probably embed the link without URL encoding the redirect parameter.

Something like this:

<a href="http://wpdiscourse.test/?discourse_sso=1&redirect_to=http://wpdiscourse.test/">Log in with Discourse</a>

(Lew Grothe) #19

I think I’m also looking for this functionality. Has this modification been made yet? If so, is it available?


(Simon Cossar) #20

No, but thanks for the reminder. I wrote the code for it, but didn’t add it to the main plugin yet. I’ll try to get it into an update that’s going out tomorrow.