Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(openid): correctly set contact_location while creating session #11613

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Centreon/Domain/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ class Contact implements UserInterface, ContactInterface
*/
private $timezone;

/**
* @var int
*/
private int $timezoneId;

/**
* @var string|null $locale locale of the user
*/
Expand All @@ -188,6 +193,25 @@ class Contact implements UserInterface, ContactInterface
*/
private $theme;

/**
* @param int $timezoneId
* @return self
*/
public function setTimezoneId(int $timezoneId): self
{
$this->timezoneId = $timezoneId;

return $this;
}

/**
* @return int
*/
public function getTimezoneId(): int
{
return $this->timezoneId;
}

/**
* @return int
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Centreon/Domain/Contact/Interfaces/ContactInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

interface ContactInterface
{
/**
* @return int Returns the timezone id
*/
public function getTimezoneId(): int;

/**
* @return int Returns the contact id
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ private function createContact(array $contact): Contact
->setAccessToApiRealTime($contact['reach_api_rt'] === '1')
->setAccessToApiConfiguration($contact['reach_api'] === '1')
->setTimezone(new \DateTimeZone($contactTimezoneName))
->setTimezoneId((int) $contact['contact_location'])
->setLocale($contactLocale)
->setDefaultPage($page)
->setUseDeprecatedPages($contact['show_deprecated_pages'] === '1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function __invoke(LoginOpenIdSessionRequest $request, LoginOpenIdSessionP
'contact_autologin_key' => '',
'contact_admin' => $user->isAdmin() ? '1' : '0',
'default_page' => $user->getDefaultPage(),
'contact_location' => $user->getLocale(),
'contact_location' => (string) $user->getTimezoneId(),
'show_deprecated_pages' => $user->isUsingDeprecatedPages(),
'reach_api' => $user->hasAccessToApiConfiguration() ? 1 : 0,
'reach_api_rt' => $user->hasAccessToApiRealTime() ? 1 : 0
Expand Down