Wp-discourse getting odd data from wp - debug help?

Issue I have a few users in WP (sso provider) that cannot login to Discourse. It appears that the email address being sent is that of another user id.

Background So, I installed wp and wp-discourse and it all worked fine. Then I accidentally eased my wp instance. I re-installed, re-connected, re-created test users… possibly different usernames, probably different id’s. Now some of the original users cannot login to discourse. I presumed that the email address was the only identifier, but it seems that user id’s are used as ident’s and email addresses are used as credentials? Not quite sure.

Example Here is an example: from the Discourse log after enabling sso logging.

I have sanitized all data with either 4-ValidData or 5-ValidData representing actual, valid data from User 4 and User 5 respectively. User 5 is trying to login, but being denied access since user 4’s external id, name, username and email are being provided.

Verbose SSO log: Record was invalid: User  4-ValidData
{:primary_email=>"has already been taken"}

Attributes:
{"admin"=>true, "moderator"=>false, "locale"=>nil, "name"=>" 4-ValidData", "title"=>nil, "username"=>" 4-ValidData"}

SSO Diagnostics:
add_groups: 
admin: 
moderator: 
avatar_force_update: true
avatar_url: 
bio: 
card_background_url: 
email: 4-ValidData
external_id: 5-ValidData
groups: 
locale: 
locale_force_update: 
name: 5-ValidData
nonce: 0ba19b8ac5e9e27e351fcd22df44e2a6
profile_background_url: 
remove_groups: 
require_activation: true
return_sso_url: 
suppress_welcome_message: 
title: 
username: 5-ValidData
website: 

This is probably the source of the problem. Since the require_activation SSO parameter is set to true, users will not be matched by email address when they login to Discourse - instead, Discourse will search for a user with an external_id that matches the WordPress user. If no user with the external_id from the SSO payload exists, Discourse will attempt to create a new user. If when attempting to create the new user, a user already exists with the SSO payload’s email address, you will get the error you are seeing.

Have a look at this topic for some ideas about how to fix the problem: Debugging and fixing common DiscourseConnect issues.

Did you create your test users manually through the WordPress admin section? How are regular users registering on your WordPress site?

If you are using the default WordPress registration system, the require_activation SSO parameter will be set to false. The reason for this is that the email address will have been verified on WordPress. When require_activation is set to false, existing Discourse users will be matched with WordPress users by their email address.

5 Likes

Thank you for the detailed explanation. I am rebuilding it all… :wink: