Pārlūkot izejas kodu

Se agrego el campo tenancyCurrent al OAuthUser

Guillermo Espinoza 7 gadi atpakaļ
vecāks
revīzija
b00d775523

+ 9 - 0
OAuth/Response/PathUserResponse.php

@@ -18,6 +18,7 @@ class PathUserResponse extends \HWI\Bundle\OAuthBundle\OAuth\Response\PathUserRe
         'profilepicture' => null,
         'roles' => null,
         'tenancies' => null,
+        'tenancyCurrent' => null,
     );
 
     /**
@@ -36,4 +37,12 @@ class PathUserResponse extends \HWI\Bundle\OAuthBundle\OAuth\Response\PathUserRe
         return $this->getValueForPath('tenancies');
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function getTenancyCurrent()
+    {
+        return $this->getValueForPath('tenancyCurrent');
+    }
+
 }

+ 1 - 0
Resources/config/hwioauthbundle/config.yml

@@ -17,6 +17,7 @@ hwi_oauth:
                 lastname: lastname
                 roles: roles
                 tenancies: tenancies
+                tenancyCurrent: tenancyCurrent
     firewall_names: [secured_area]
 
 doctrine:

+ 21 - 0
Security/Core/User/CustomOAuthUser.php

@@ -17,6 +17,11 @@ class CustomOAuthUser extends OAuthUser
      */
     protected $tenancies = array();
 
+    /**
+     * @var array
+     */
+    protected $tenancyCurrent = array();
+
 
     /**
      * {@inheritdoc}
@@ -50,4 +55,20 @@ class CustomOAuthUser extends OAuthUser
         $this->tenancies = $tenancies;
     }
 
+    /**
+     * @return array
+     */
+    public function getTenancyCurrent()
+    {
+        return $this->tenancyCurrent;
+    }
+
+    /**
+     * @param array $tenancyCurrent
+     */
+    public function setTenancyCurrent($tenancyCurrent)
+    {
+        $this->tenancyCurrent = $tenancyCurrent;
+    }
+
 }

+ 1 - 0
Security/Core/User/CustomOAuthUserProvider.php

@@ -53,6 +53,7 @@ class CustomOAuthUserProvider extends OAuthUserProvider
         $user = $this->loadUserByUsername($response->getNickname());
         $user->setRoles($response->getRoles());
         $user->setTenancies($response->getTenancies());
+        $user->setTenancyCurrent($response->getTenancyCurrent());
         $token = new UsernamePasswordToken($user, null, "secured_area", $user->getRoles());
         $this->securityTokenStorage->setToken($token);