Example #1
0
 public function editSave($data)
 {
     $password = Hash::create('sha256', $data['password'], HASH_PASSWORD_KEY);
     $user = new User();
     $existingUser = $user->findById($data['id']);
     $existingUser->setId($data['id']);
     $existingUser->setLogin($data['login']);
     $existingUser->setPassword($password);
     $existingUser->setRole($data['role']);
     $existingUser->update(true);
 }
Example #2
0
 /**
  * Save if user doesn't exists else update the existing.
  * Check the user by email.
  * @param type $data
  */
 function updateUser($data)
 {
     $user = $this->getUserByEmail($data["email"]);
     if ($user == null) {
         $user = $this->getUserByFBID($data["fb_id"]);
     }
     if ($user == null) {
         $user = new User();
     }
     $user->setEmail($data["email"]);
     $user->setFirstName($data["first_name"]);
     $user->setLastName($data["last_name"]);
     $user->setFbtoken($data["long_lived_access_token"]);
     $user->setFbid($data["fb_id"]);
     $user->setGender($data["gender"]);
     $imageURL = $this->getImageFromFacebook($data["fb_id"]);
     $user->setImageURL($imageURL);
     $db = new DB();
     $user = $db->update($user, true);
     return $user;
 }