vikaspotluri123 / discourse-on-ghost

Add Ghost-based SSO to Discourse
https://github.vikaspotluri.me/discourse-on-ghost
MIT License
24 stars 3 forks source link

Member changes not synced #219

Open DenisDoroshchuk opened 4 weeks ago

DenisDoroshchuk commented 4 weeks ago

Hello,

So I have Discourse, I also have Ghost CMS. I'm trying to connect them using DoG. I have done everything step by step from the instructions. SSO works fine, I can access Discourse through the Ghost site. Thanks! But webhooks I can't get it to work.

My .env file:

Screenshot 2024-10-29 at 13 25 29

My webhooks in Ghost:

Screenshot 2024-10-29 at 13 29 08

I change the username in Ghost but nothing happens in Discourse, the name doesn't change but the hook is sent. This is what I see in Ghost logs (I changed my domain to mysite.com): {"name":"Log","hostname":"ghost-staging","pid":263833,"level":30,"version":"5.88.2","msg":"Triggering webhook for \"member.edited\" with url \"https://mysite.com/ghost/api/external_discourse_on_ghost/hook/a5dce7f74fca6254d6115419\"","time":"2024-10-29T12:18:55.622Z","v":0} {"name":"Log","hostname":"ghost-staging","pid":263833,"level":40,"version":"5.88.2","msg":"Request to https://mysite.com/ghost/api/external_discourse_on_ghost/hook/a5dce7f74fca6254d6115419 failed because of: ERR_NON_2XX_3XX_RESPONSE.","time":"2024-10-29T12:18:55.653Z","v":0}

Can you help me figure this out? Again, SSO works fine, i.e. the path /ghost/api/external_discourse_on_ghost/ is configured in nginx.

Thank you, Denis D.

vikaspotluri123 commented 4 weeks ago

Hey @DenisDoroshchuk 👋🏾 For DoG to process webhooks, you need to update DOG_GHOST_MEMBER_WEBHOOKS_ENABLED to true. But the other thing is that the webhooks only handle subscription changes today; for user changes to sync I think you they will need to log out/in to Discourse

DenisDoroshchuk commented 4 weeks ago

Hey @vikaspotluri123 Thanks for the quick reply. Yes indeed, changing the tier does work. I tried logging out of Discourse and logging in again via SSO, but the username did not change.

vikaspotluri123 commented 4 weeks ago

Ghost doesn't have the concept of a username for members, right? As part of SSO, the email, avatar, and potentially name are synced.

DenisDoroshchuk commented 4 weeks ago

@vikaspotluri123 Sorry for the confusion, I may have worded it oddly. I would like to be able to change the Name field in Discourse after changing the Name field in Ghost.

Screenshot 2024-10-30 at 08 21 00
vikaspotluri123 commented 4 weeks ago

Thanks! I'll need to debug this a bit so I won't be able to get to it until this weekend or next weekend

DenisDoroshchuk commented 4 weeks ago

Thank you @vikaspotluri123 ! I will wait answer from you.

vikaspotluri123 commented 3 weeks ago

I'm able to reproduce this behavior, thanks for reporting! The member data sent by DoG is correct, so I need to debug why Discourse is ignoring it (it's probably an issue with DoG).

vikaspotluri123 commented 3 weeks ago

Well that was fast! There's a site setting called auth_overrides_name that needs to be enabled for Ghost's member name to be used.

DenisDoroshchuk commented 2 weeks ago

Thank you @vikaspotluri123 I checked it out and it does work fine. But only if the user logs out and logs in again via SSO. This setting:

Screenshot 2024-11-07 at 10 13 03
vikaspotluri123 commented 2 weeks ago

I checked it out and it does work fine. But only if the user logs out and logs in again via SSO.

Yes, that's a current limitation:

But the other thing is that the webhooks only handle subscription changes today; for user changes to sync I think you they will need to log out/in to Discourse

vikaspotluri123 commented 4 days ago

The docs have been updated to highlight this behavior. Keeping this issue open to track the enhancement.