Hello,

Thanks for your work on this module. One feature I think is missing is the ability for users who already have accounts on the site to link to their Patreon account. (Currently, new users can register an account, but there doesn't seem to be an option for existing users - unless I'm missing something?)

Ideally I think a button on the user edit / account page, "Authorize with Patreon" or something to that effect, which launches the Oauth method at Patreon. Users login to Patreon and then are redirected to the site and are authenticated.

It seems like this functionality already exists in the module, but the methods are contained within the module's provided login blocks which only show for anonymous users.

I can probably write a patch for this, as it seems like it might be a simple addition.

Comments

torgosPizza created an issue. See original summary.

mrdalesmith’s picture

Status: Active » Needs work

Hi @torgosPizza

That sounds like a useful bit of functionality, yes: I'll wait for a patch then :)

torgospizza’s picture

StatusFileSize
new5.82 KB

Finally, here's a patch which does the following:

  • Adds a "Link your account" link block which also checks if the user is currently a patron or not.
  • Removes some calls to user_is_anonymous() in the OAuth callback.
  • Separates out the logic in the oauth callback depending on if the user is logged in or not.
  • If the user is already logged in, show a success message and then redirect. Otherwise, log in as before.

Please review and test. (I also recommend applying the other child patches first, to make sure things like the Patreon ID are assigned to the account during this process.)

Thanks!

torgospizza’s picture

Status: Needs work » Needs review

mrdalesmith’s picture

Cheers for the patch: I've committed into a new dev version of 7.2 to allow for testing.

torgospizza’s picture

Status: Needs review » Needs work

I found an issue in the call to patreon_fetch_user() that makes the module broken when this block is enabled. It seems to use an expired token, resulting in a "your token has expired or is invalid" error. It might require some static caching, which we can update when the token is refreshed. Need to dig in more, but for now setting to Needs Work until I can update the patch.

mrdalesmith’s picture

I've added a link to Use external PHP library to handle Oauth on this ticket, as if I implement that it may well resolve the issue you've had here. It may be a while before I've done it though, as I'll develop against 8 first and then backport.

mrdalesmith’s picture

Status: Needs work » Closed (outdated)