Skip to content
Merged
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
9 changes: 7 additions & 2 deletions lib/Controller/TimezoneController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -17,10 +18,10 @@
class TimezoneController extends Controller {

public function __construct(
$appName,
string $appName,
IRequest $request,
private readonly IConfig $config,
private $userId,
private ?string $userId,
private readonly ISession $session,
) {
parent::__construct($appName, $request);
Expand All @@ -30,8 +31,12 @@ public function __construct(
* @NoAdminRequired
* @UseSession
* @throws \OCP\PreConditionNotMetException
* @throws \InvalidArgumentException
*/
public function setTimezone(string $timezone, int $timezoneOffset): JSONResponse {
if (!in_array($timezone, \DateTimeZone::listIdentifiers())) {
throw new \InvalidArgumentException('Invalid timezone');
}
$this->config->setUserValue($this->userId, 'core', 'timezone', $timezone);
$this->session->set('timezone', $timezoneOffset);

Expand Down
Loading