Problem/Motivation

Many social networks provides users' profile pictures when the users login with their social network accounts.

Proposed resolution

We need to provide a method to download those pictures from the url provided by these APIs and store them as pictures for users in the Drupal site.

Comments

gvso created an issue. See original summary.

gvso’s picture

Issue summary: View changes
slivorezka’s picture

Hi,

I added a method to store user's picture.
Please check it.

Thanks,
Andrew

gvso’s picture

Status: Active » Needs work

Thanks @slivorezka

I can't apply the patch. I get

Checking patch SocialAuthUserManager.php...
error: SocialAuthUserManager.php: No such file or directory
slivorezka’s picture

Hi @gvso

I updated the patch.
Please check it again.

Thanks,
Andrew

gvso’s picture

Thanks @slivorezka

  1. +++ b/src/SocialAuthUserManager.php
    @@ -27,11 +38,28 @@ class SocialAuthUserManager {
    +    $this->eventDispatcher    = $event_dispatcher;
    

    The event dispatcher is not being used anywhere.

  2. +++ b/src/SocialAuthUserManager.php
    @@ -247,4 +275,143 @@ class SocialAuthUserManager {
    +  protected function downloadProfilePic($picture_url, $id) {
    +    // Make sure that we have everything we need.
    +    if (!$picture_url || !$id) {
    

    This method should be generic. Why is it the id a parameter? I guess It should only receive an url or we should find a different way to generate the file name. Maybe a facebook account has the id 1234, but another Google account also has the id 1234.

slivorezka’s picture

Hi @gvso,
I removed Event Dispatcher and implemented additional argument "provider".
Well if some accounts have the same ID it will have look like facebook_123 OR google_123

Thanks

gvso’s picture

Status: Needs work » Needs review
gvso’s picture

Status: Needs review » Needs work

Thanks again.

  1. +++ b/src/SocialAuthUserManager.php
    @@ -27,11 +37,25 @@ class SocialAuthUserManager {
    -  public function __construct(ConfigFactoryInterface $config_factory, LoggerChannelFactoryInterface $logger_factory, EntityTypeManagerInterface $entity_type_manager) {
    

    You have included new arguments in the construct method, but the service definition hasn't been updated in social_auth.services.yml

  2. +++ b/src/SocialAuthUserManager.php
    @@ -247,4 +271,147 @@ class SocialAuthUserManager {
    +        ->error('Could not download Twitter profile picture from url: @url', array('@url' => $picture_url));
    

    Maybe we can use the provider argument to create this message.

slivorezka’s picture

Hi @gvso,

Well I did some code refactor and now must be all Ok.
Please check it again.

Thanks,
Andrew

gvso’s picture

Status: Needs work » Needs review
nikathone’s picture

Reroll the patch on number 10 to apply on latest dev.

gvso’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Because of #2843056: Provide on login and create user event dispatchers, this patch can not longer be applied.

nikathone’s picture

And here is the rerolled patch.

nikathone’s picture

Status: Needs work » Needs review
gvso’s picture

Status: Needs review » Needs work
index 99e334f..66fd708 100644
--- a/README.txt

--- a/README.txt
+++ b/README.txt

+++ b/README.txt
@@ -1,15 +1,24 @@

@@ -1,15 +1,24 @@
 INTRODUCTION
 ------------

Changes to README file have also been added here

nikathone’s picture

What changes specifically should be added to the README.txt? In the meantime I did fetch the current dev na d here is the patch.

nikathone’s picture

Status: Needs work » Needs review

  • gvso committed 25d56f1 on 8.x-1.x
    Issue #2779641 by slivorezka, nikathone: Provide method to store user's...
gvso’s picture

Status: Needs review » Active

Committed with some changes. Thanks everyone.

We need to add this to Social Auth Example, as well as to all implementers in drupal.org

gvso’s picture

Status: Active » Fixed

Just committed the changes to Social Auth Examples. Only implementers are missing, but that's not part of this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.