Skip to content

Commit

Permalink
Merge pull request #5 from arcanys/master
Browse files Browse the repository at this point in the history
address issue where new attributes are not being stored in the User E…
  • Loading branch information
djaney committed Nov 16, 2015
2 parents 5538031 + 92edf25 commit 17c263b
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions Security/User/SSOUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ public function loadUserByUsername($userData)
$user = new $this->class();
$new = true;
}
if(isset($userData['username']))
$user->setUsername($userData['username']);
if(isset($userData['email']))
$user->setEmail($userData['email']);
if(isset($userData['firstname']))
$user->setFirstname($userData['firstname']);
if(isset($userData['lastname']))
$user->setLastname($userData['lastname']);
if(isset($userData['roles']))
$user->setRoles($userData['roles']);
if(isset($userData['token']))
$user->setToken($userData['token']);

if($new){
$this->doctrine->getManager()->persist($user);
}
foreach ($userData as $name => $value) {
$set_method = 'set'.ucfirst($name);
$get_method = 'get'.ucfirst($name);
if (method_exists($user, $set_method) && method_exists($user, $get_method)) {
if($user->$get_method() != $value) {
$user->$set_method($value);
$new = true;
}
}
}

if($new){
$this->doctrine->getManager()->persist($user);
}

$this->doctrine->getManager()->flush();

Expand Down

0 comments on commit 17c263b

Please sign in to comment.