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

Commit

Permalink
fix(openid): correctly set contact_location while creating session (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjaouen authored Aug 26, 2022
1 parent c14ad3b commit 51dc751
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/Centreon/Domain/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ class Contact implements UserInterface, ContactInterface
*/
private $timezone;

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

/**
* @var string|null $locale locale of the user
*/
Expand Down Expand Up @@ -189,6 +194,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

0 comments on commit 51dc751

Please sign in to comment.