Browse Source

identify user with email to during facebook connect

Bastien Sevajol 11 years ago
parent
commit
720b2cb0f7

+ 9 - 2
src/Muzich/CoreBundle/Security/User/Provider/FacebookProvider.php View File

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

+ 5 - 0
src/Muzich/UserBundle/Entity/UserManager.php View File

80
     
80
     
81
     return $result;
81
     return $result;
82
   }
82
   }
83
+  
84
+  public function canonicalizeEmailLocal($email)
85
+  {
86
+    return $this->emailCanonicalizer->canonicalize($email);
87
+  }
83
 
88
 
84
 }
89
 }