Is it possible to make sso.avatar_url work on the first login?


#1

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. Is there anyway to get this to work from the first login instead of them having to log out and back in again before seeing the avatar changed?


(Simon Cossar) #2

That doesn’t sound right. The avatar should be set the first time the user logs into Discourse.

What version of Discourse are you using?


#3

Version taken from the < head > is

1.8.0.beta4


#4

I have made changes to:

enable sso
sso url
sso secret
sso_overrises_avatar

did I miss anything necessary to get this to work on the first login?


(Simon Cossar) #5

What is the website that you are using as the SSO provider? Is it WordPress or something else?


#6

No, it is a ruby on rails app hosted by heroku.


(Simon Cossar) #7

The Discourse code for setting the SSO avatar is here:

You could try setting force_avatar_update=true in the parameters you are sending to Discourse.


#8

No, it is the same situation. I have to login once and see the standard letter avatar and then on logging out and logging back in again, the avatar is updated.


#9

Does it work on the first login in your app Simon?


(Simon Cossar) #10

Yes it’s set correctly on the first login. I’m using WordPress with the wp-discourse plugin. There is an issue with the avatar image not updating if it’s ever changed. This is because WordPress generally sets the avatar image using Gravatar. This will be fixed on the next update of the plugin.

If it helps, the wp-discourse SSO code is here:
https://github.com/discourse/wp-discourse/blob/beta/lib/discourse-sso.php#L184