/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/users/src/Controller/Traits
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/users/src/Controller/Traits/ProfileTrait.php (2292B)
getRequest()->getAttribute('identity');
$identity = $identity ?? [];
$loggedUserId = $identity['id'] ?? null;
$isCurrentUser = false;
if (!Configure::read('Users.Profile.viewOthers') || empty($id)) {
$id = $loggedUserId;
}
try {
$appContain = (array)Configure::read('Auth.authenticate.' . AuthComponent::ALL . '.contain');
$socialContain = Configure::read('Users.Social.login') ? ['SocialAccounts'] : [];
$user = $this->getUsersTable()->get($id, [
'contain' => array_merge((array)$appContain, (array)$socialContain),
]);
$this->set('avatarPlaceholder', Configure::read('Users.Avatar.placeholder'));
if ($user->id === $loggedUserId) {
$isCurrentUser = true;
}
} catch (RecordNotFoundException $ex) {
$this->Flash->error(__d('cake_d_c/users', 'User was not found'));
return $this->redirect($this->getRequest()->referer());
} catch (InvalidPrimaryKeyException $ex) {
$this->Flash->error(__d('cake_d_c/users', 'Not authorized, please login first'));
return $this->redirect($this->getRequest()->referer());
}
$this->set(compact('user', 'isCurrentUser'));
$this->set('_serialize', ['user', 'isCurrentUser']);
}
}