Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove automagic timezone changing #32371

Closed
wants to merge 1 commit into from
Closed

Remove automagic timezone changing #32371

wants to merge 1 commit into from

Conversation

tomneedham
Copy link
Contributor

Description

No automagic timezone set on login, which doesnt work when using SSO, in favour of selector in personal settings. Later, we could add the auto detection to flag up that you are in a different timezone, and maybe you want to change your settings to your current timezone.

Related Issue

Motivation and Context

Automagic timezone changing when you travel affects everything you see in ownCloud, including activity emails. If you don't 'login' then this wont happen, so it is unreliable. AND this only happens when using the login form, SSO does not use this.

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Nothing set, default when you login:
screen shot 2018-08-17 at 13 16 15

When you have a timezone set, or preset by your admin (oc_preferences table, app=core, configkey=timezone)
screen shot 2018-08-17 at 13 15 48

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)
  • Not sure if timezone lib is used elsewhere, remove from package.json ?
  • Unit tests on SetTimezoneController

@tomneedham
Copy link
Contributor Author

Codestyle and unit tests need to be updated - can do if this is the way we want to go... @PVince81

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, see comments.

I wonder if we need a "default" choice or "auto" which would fall back to the old behavior.

@@ -58,7 +56,7 @@
<?php p($_['user_autofocus'] ? '' : 'autofocus'); ?>
autocomplete="on" autocapitalize="off" autocorrect="off" required>
<label for="password" class="infield"><?php p($l->t('Password')); ?></label>
<input type="submit" id="submit" class="login primary icon-confirm" title="<?php p($l->t('Log in')); ?>" value="" disabled="disabled"/>
<input type="submit" id="submit" class="login primary icon-confirm" title="<?php p($l->t('Log in')); ?>" value=""/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the disabled property ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it was enabled when the timezone was set - so without removing this it is always disabled

@@ -152,6 +153,15 @@ public function __construct(array $urlParams=[]) {
$c->query('Config')
);
});
$container->registerService('SetTimezoneController', function (IContainer $c) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call it just "TimezoneController maybe, who knows what future methods it will have like for example querying all supported timezones ?

namespace OC\Settings\Controller;

use OC\AppFramework\Http;
use \OCP\AppFramework\Controller;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove leading backslash for consistency ?

IConfig $config,
IL10N $l,
IUserSession $session) {
parent::__construct($appName, $request);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting is weird, not really readable.
I think you should move the ) { on the next line

public function set() {

$available = \DateTimeZone::listIdentifiers();
if (!in_array($this->request->getParam('timezoneInput'), $available)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always add true in in_array to make it strict (doesn't PHPStorm mention this?)

'core',
'timezone',
null));
$timezoneSelector->assign('timezones', \DateTimeZone::listIdentifiers());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ok for now.

will not work for Phoenix, so we'll later need to add a get method on the TimezoneController so Phoenix knows what values to use to populate. this is only to push my aadvice to rename SetTimezoneController to TimezoneController

@@ -230,12 +230,25 @@ $(document).ready(function () {
location.reload();
}
else {
$('#passworderror').text(data.data.message);
OC.Notification.showTemporary(t('settings', 'Error saving language: {message}', { message: data.data.message }));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error saving timezone, not language ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is language - see whole file. The language save error handler was piggy backing on the password error div for its error message 🙈 which gets worse, when I was testing with LDAP so there was no password change box.

}
});
return false;
});

$("#timezoneInput").change(function () {
// Serialize the data
var post = $("#timezoneInput").serialize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhhh, never saw this serialize method before

@PVince81
Copy link
Contributor

@pmaier1 FYI

@pmaier1
Copy link
Contributor

pmaier1 commented Aug 22, 2018

👍 Maybe you want to rename the default timezone simply to "Default" (instead of "Server default" which I find unnecessary technical :) )

@tomneedham
Copy link
Contributor Author

Actually talked to @DeepDiver1975 and he pointed out the solution for timezone addition in shibboleth. So maybe we keep it, but allow manual setting of it?

@DeepDiver1975
Copy link
Member

Actually talked to @DeepDiver1975 and he pointed out the solution for timezone addition in shibboleth. So maybe we keep it, but allow manual setting of it?

unless I finally understand the need to remove the auto-setting of timezone from the login page I prefer to keep it. We recently fixed it to solve some customer time zone issues.

Having an manual select option is fine.

@codecov
Copy link

codecov bot commented Aug 23, 2018

Codecov Report

Merging #32371 into master will decrease coverage by 15.98%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #32371       +/-   ##
=============================================
- Coverage     64.01%   48.02%   -15.99%     
=============================================
  Files          1176      109     -1067     
  Lines         70233    10394    -59839     
  Branches       1267     1267               
=============================================
- Hits          44961     4992    -39969     
+ Misses        24902     5032    -19870     
  Partials        370      370
Flag Coverage Δ Complexity Δ
#javascript 52.84% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 37.32% <ø> (-27.96%) 0 <ø> (-18666)
Impacted Files Coverage Δ Complexity Δ
lib/private/Files/Storage/DAV.php 59.45% <0%> (-21.64%) 0% <0%> (ø)
...ate/Files/External/Service/UserStoragesService.php
lib/private/L10N/L10N.php
apps/files_trashbin/lib/Expiration.php
...mments/tests/unit/Dav/EntityTypeCollectionTest.php
lib/base.php
apps/updatenotification/templates/admin.php
lib/private/DB/Connection.php
lib/private/Config.php
apps/federatedfilesharing/lib/TokenHandler.php
... and 1055 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b30659c...634fba6. Read the comment docs.

@tomneedham
Copy link
Contributor Author

Pushed to address comments. @pmaier1 to decide if we want only automagic, automagic+manual option, or only manual? I can update this PR accoridingly

@pmaier1
Copy link
Contributor

pmaier1 commented Aug 23, 2018

Well, I agree a lot with #32165 (comment) and #32165 (comment) so I would tend to only go for the manual option. Still I want to respect @DeepDiver1975 in #32371 (comment). @DeepDiver1975 does the reasoning in the first two comments make sense to you or why would you want to keep automagic?

Depending on @DeepDiver1975's answer I'd say we either:

  • make the compromise and keep automagic but add the manual option additionally
  • just go for the manual option

Question for the compromise way: When users set the manual option, would that imply disabling automagic then?

@tomneedham
Copy link
Contributor Author

Question for the compromise way: When users set the manual option, would that imply disabling automagic then?

In this case, I would suggest an 'option' in the dropdown is 'auto'. If you select 'uk/london' you automatically unselect auto.

@pmaier1
Copy link
Contributor

pmaier1 commented Aug 23, 2018

Nice, I think that's the way to go 👌

@DeepDiver1975
Copy link
Member

Okay - so to open the can of worms completly:

  • generally speaking the server should send any timestamps in a timezone neutral form or with the explicit timezone when
  • any client has to convert this timestamp to the time zone of the local client

This way the client will always get the time right - thinking about the traveling use case.

The only reason why the user needs to specify the timezone in the server is for server side generated content - like emails. In this case one does not know the timezone of the client.
Therefore we need the setting.

^ all this applies to language exactly the same way - with one additional feature: there is a http header Accept-Language which the client is sending to the server to tell the desired language. This was the server can generate content in the correct language. There is no Accept-TimeZone header ... just in case you are asking ;-)

@pmaier1
Copy link
Contributor

pmaier1 commented Aug 23, 2018

generally speaking the server should send any timestamps in a timezone neutral form or with the explicit timezone when

The server can do that still, right? If I'm not mistaken the only question to answer here is: Do I want to set a fixed timezone on the server or do I want it to dynamically change on login. Clients can then still convert it as they wish to.

Not sure if I get all implications right.

  • When using automagic timezone the drawback is that server-generated things like mails use the timezone that was detected on last login. This implies that the timing of these actions follows users when travelling.
  • When using a fixed timezone the drawback is that the time in the webUI will not match when I'm in a different timezone as long as I don't change it it in the settings

I'm missing some examples to get a better understanding of the implications.

@PVince81
Copy link
Contributor

Hmmm, is the web UI even affected by the timezone change ? I'm not sure.

Maybe the setting could be called "Timezone to use in email communication" or something related to server-only things ?

@tomneedham
Copy link
Contributor Author

Maybe the setting could be called "Timezone to use in email communication" or something related to server-only things ?

By this point, we are creating a mess for end users......

@tomneedham
Copy link
Contributor Author

Closing this as this only affects users of custom user backends - and their specific implementations.

@tomneedham tomneedham closed this Oct 1, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User timezone is not updated when using auth methods != credentials
5 participants