Sso overrides avatar

AI 生成的摘要

The discussion revolves around the issue of SSO overrides not updating user avatars in Discourse. homebrewhops noticed that users who set their avatar in WordPress display a default Gravatar in Discourse. pfaffman suggested that avatars don’t get updated until users log in again.

simon investigated the issue and found that the avatar_url is only used when the user’s profile picture is set to use the ‘system assigned profile picture’. The sso overrides avatar setting in Discourse doesn’t seem to work as expected, making it impossible for users to edit their profile picture.

simon further discovered that the issue is due to the avatar_changed test in discourse_single_sign_on.rb failing when the WordPress avatar is set using Gravatar. A possible solution is to send the parameter avatar_force_update = 'true' with the SSO parameters, but this overrides the sso_overrides_avatar setting.

Mie_Goreng shared their code and observed that a user’s avatar doesn’t change on the first login, but changes after logging out and logging back in again.

I’ve read through these:

https://github.com/discourse/discourse/commit/0791c2c96636e9af5992d5d0ea6f991018cf4ef6

Users who have set their avatar (via picture upload) in wordpress display a default gravatar in Discourse.

Comparing Discourse users, they have separate gravatar URLs:

http://0.gravatar.com/avatar/6d4c49710ee6a33fa4e8a674e7c10523?s=96&d=mm&r=g

http://0.gravatar.com/avatar/c2347da352720d16473af84bcacb7924?s=96&d=mm&r=g

What do I begin to look at to diagnose this?

I believe that the avatars don’t get updated until they log in again.

I’ve tried this out in my local development environment and there seems to be a problem with the way it’s working. The avatar_url is being sent to Discourse on login, but it is only being used by Discourse when the user’s profile picture is set to use the ‘system assigned profile picture’. This change - from the system assigned image to the SSO image - only works once. After the system assigned image is overridden by the SSO image it becomes a ‘custom picture’ and is not overwritten when the SSO avatar is changed.

Also, the Discourse setting ‘sso overrides avatar’ doesn’t seem to be doing anything except making it impossible for a user to edit their profile picture on Discourse.

What seem to be happening is that when WordPress avatar is set using Gravatar, changing the Gavatar doesn’t change the avatar URL, so the test for avatar_changed in discourse_single_sign_on.rb is failing.

I can change the wp_discourse plugin to send the parameter avatar_force_update = 'true' with the SSO parameters. That works, but it overrides the Discourse setting sso_overrides_avatar, so it will change user avatars when that setting isn’t selected.

Here is my code:

sso.avatar_url = current_user.photo.thumb.url

A user logs into the discourse for the first time, their avatar does not change.

They log out.

Now on logging back in again, the avatar is changed.