FEATURE: import Github profile picture

This commit is contained in:
Kyle Zhao
2017-08-21 19:14:26 -04:00
parent 93fe76fc02
commit 49f0119c12
2 changed files with 63 additions and 9 deletions

View File

@ -91,6 +91,8 @@ class Auth::GithubAuthenticator < Auth::Authenticator
end
end
retrieve_avatar(user, data)
result.user = user
result
end
@ -102,6 +104,8 @@ class Auth::GithubAuthenticator < Auth::Authenticator
screen_name: data[:github_screen_name],
github_user_id: data[:github_user_id]
)
retrieve_avatar(user, data)
end
def register_middleware(omniauth)
@ -113,4 +117,15 @@ class Auth::GithubAuthenticator < Auth::Authenticator
},
scope: "user:email"
end
protected
def retrieve_avatar(user, data)
return unless user
return if user.user_avatar&.custom_upload_id.present?
if (avatar_url = data[:image]).present?
Jobs.enqueue(:download_avatar_from_url, url: avatar_url, user_id: user.id, override_gravatar: false)
end
end
end