Преглед на файлове

identify user with email to during facebook connect

Bastien Sevajol преди 11 години
родител
ревизия
720b2cb0f7
променени са 2 файла, в които са добавени 14 реда и са изтрити 2 реда
  1. 9 2
      src/Muzich/CoreBundle/Security/User/Provider/FacebookProvider.php
  2. 5 0
      src/Muzich/UserBundle/Entity/UserManager.php

+ 9 - 2
src/Muzich/CoreBundle/Security/User/Provider/FacebookProvider.php Целия файл

@@ -36,6 +36,11 @@ class FacebookProvider implements UserProviderInterface
36 36
     return $this->userManager->findUserBy(array('facebook_id' => $fbId));
37 37
   }
38 38
 
39
+  public function findUserByEmail($email)
40
+  {
41
+    return $this->userManager->findUserBy(array('email' => $this->userManager->canonicalizeEmailLocal($email)));
42
+  }
43
+
39 44
   public function loadUserByUsername($username)
40 45
   {
41 46
     $user = $this->findUserByFbId($username);
@@ -46,7 +51,9 @@ class FacebookProvider implements UserProviderInterface
46 51
       throw new UsernameNotFoundException('The user is not authenticated on facebook');
47 52
       $fbdata = null;
48 53
     }
49
-
54
+    
55
+    $user = $this->findUserByEmail($fbdata['email']);
56
+    
50 57
     if (!empty($fbdata)) {
51 58
       if (empty($user)) {
52 59
         $user = $this->userManager->getNewReadyUser();
@@ -71,7 +78,7 @@ class FacebookProvider implements UserProviderInterface
71 78
     if (!$this->supportsClass(get_class($user)) || !$user->getFacebookId()) {
72 79
       throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
73 80
     }
74
-
81
+    
75 82
     return $this->loadUserByUsername($user->getFacebookId());
76 83
   }
77 84
 }

+ 5 - 0
src/Muzich/UserBundle/Entity/UserManager.php Целия файл

@@ -80,5 +80,10 @@ class UserManager extends UserManagerBase
80 80
     
81 81
     return $result;
82 82
   }
83
+  
84
+  public function canonicalizeEmailLocal($email)
85
+  {
86
+    return $this->emailCanonicalizer->canonicalize($email);
87
+  }
83 88
 
84 89
 }