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

Timezone not set when user created through oidc-login #229

Closed
mathsyx69 opened this issue Jun 1, 2023 · 4 comments
Closed

Timezone not set when user created through oidc-login #229

mathsyx69 opened this issue Jun 1, 2023 · 4 comments

Comments

@mathsyx69
Copy link
Contributor

mathsyx69 commented Jun 1, 2023

Hello,

I have a problem with the automatic creation of users via the Azure connection. When the user is created, the timezone entry in the oc_preferences table of the nextcloud database is not created.
The default timezone for the account is UTC.

When the user receives activity notifications by e-mail, the time of the event is out of sync with French time in my case.

To correct this bug, all you have to do is manually add the entry to the database using the commands below:

mysql -u root -p
USE nextcloud;
INSERT INTO `oc_preferences` (`userid`,`appid`,`configkey`,`configvalue`) VALUES ('---USERID---','core','timezone','Europe/Paris');
exit;

Would it be possible to correct this in code and add a modifiable parameter to the configuration?
For example: oidc_login_client_id_timezone

Thank by advance for your help.

Have a good day.

@pulsejet
Copy link
Owner

pulsejet commented Jun 4, 2023

This has nothing to do with this plugin. You need to set the correct timezone on your server (e.g. php.ini). date_default_timezone_get() should return the defaut timezone.

@mathsyx69
Copy link
Contributor Author

The timezone is set in my php.ini (/etc/php/8.1/fpm/php.ini & /etc/php/8.1/cli/php.ini )
date.timezone = "Europe/Paris"

I make a first connection with a test user and the timezone entry isn't created.

I try to execute the function you provide and the timezone is correctly set :
image

I don't understand where it comes from...

@davtheultimate
Copy link

davtheultimate commented Jul 28, 2023

Hello pulsejet,

This issue exist only with the activity sent to our user in the body of the email. the process who send activity's email try to get the timezone in the oc_preferences table. If user has no timezone configkey set so it consider time is set to UTC. and we lost 2 hours in the activity email notification because we are from 'Europe/Paris'

The standard login form from nextcloud add this value in the table oc_preferences

INSERT INTO oc_preferences (userid,appid,configkey,configvalue) VALUES ('---USERID---','core','timezone','Europe/Paris');

as described here : nextcloud/server#2560

So If we do not use the standard form from nextcloud but the plugin redirect login to keycloak form for example. The value will be never add in the table oc_preferences.

For solve this issue, I was forced to add this trigger in the database :

DELIMITER $$
CREATE TRIGGER addtimezone AFTER INSERT ON oc_ldap_user_mapping FOR EACH ROW
BEGIN
IF NOT EXISTS (SELECT 1 FROM oc_preferences WHERE userid = NEW.owncloud_name and configkey =‘timezone’) THEN
INSERT INTO oc_preferences VALUES (NEW.owncloud_name,‘core’,‘timezone’,‘Europe/Paris’);
END IF;
END $$
DELIMITER ;

Delete my existing users from oc_accounts and oc_ldap_user_mapping, force a new sync users with command : sudo -u www-data php /var/www/html/nextcloud/occ user:list.

Please, check if in your table oc_preference, all of your users who sync from an AD and who log in with keycloak had a configkey timezone set

@mathsyx69
Copy link
Contributor Author

mathsyx69 commented Apr 2, 2024

Hello,

I have mitigate this in my environnment by adding this trigger in mariadb :

USE NEXTCLOUD;
DELIMITER $$
CREATE TRIGGER addtimezone AFTER INSERT ON oc_accounts FOR EACH ROW
BEGIN
IF NOT EXISTS (SELECT 1 FROM oc_preferences WHERE userid = NEW.uid and configkey = 'timezone') THEN
INSERT INTO oc_preferences (userid,appid,configkey,configvalue) VALUES (NEW.uid,'core','timezone','Europe/Paris');
END IF;
END $$

DELIMITER ;

Thanks @davtheultimate for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants