Skip to content

Commit

Permalink
Feature/oe 11162 hotfix (#23)
Browse files Browse the repository at this point in the history
* OE-11162-hotfix: Fix validation error and user not found exception

* OE-11162-hotfix: Fix active flag

Co-authored-by: kerdorina <kerdorina@users.noreply.github.com>
  • Loading branch information
kerdorina and kerdorina authored Oct 11, 2021
1 parent d64bccb commit 63fce42
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions components/UserObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ public function updateUser($params)
if ($user->contact_id !== $contact->id) {
$user->contact_id = $contact->id;

if (!$user->save()) {
if (!$user->save(false)) {
\Yii::log("Unable to save user contact: ".print_r($user->getErrors(),true), \CLogger::LEVEL_ERROR);
throw new Exception("Unable to save user contact: ".print_r($user->getErrors(),true));
}
}
return $user;
} else {
\Yii::log("User " . $username . " not found in the CSD database.", \CLogger::LEVEL_ERROR);
throw new Exception("Unable to save user contact: ".$username);
return;
}
} catch (Exception $e) {
\Yii::log("Unable to update user. Error: ". $e->getMessage(), \CLogger::LEVEL_ERROR);
Expand Down Expand Up @@ -172,10 +172,10 @@ private function saveUser(User $user, UserAuthentication $user_authentication, a
}
$user->is_consultant = $remote_user['is_consultant'];
$user->is_surgeon = $remote_user['is_surgeon'];
$user_authentication->active = !$remote_user['active'];
$user_authentication->active = $remote_user['active'];
$user->global_firm_rights = 1;

if (!$user->save()) {
if (!$user->save(false)) {
\Yii::log('Unable to save user: '.print_r($user->getErrors(),true), \CLogger::LEVEL_ERROR);
throw new Exception('Unable to save user: '.print_r($user->getErrors(),true));
}
Expand Down Expand Up @@ -206,7 +206,7 @@ private function saveContact(User $user, Contact $contact): Contact
$contact->last_name = $user->last_name;
$contact->qualifications = $user->qualifications;

if (!$contact->save()) {
if (!$contact->save(false)) {
\Yii::log('Unable to save contact: '.print_r($contact->getErrors(),true), \CLogger::LEVEL_ERROR);
throw new Exception('Unable to save contact: '.print_r($contact->getErrors(),true));
}
Expand Down

0 comments on commit 63fce42

Please sign in to comment.