Actions
Defect #10098
openlast_login_on set to wrong time when config.active_record.default_timezone = :utc
Defect #10098:
last_login_on set to wrong time when config.active_record.default_timezone = :utc
Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
Accounts / authentication
Target version:
-
Resolution:
Affected version:
Description
reproduce
- Set config.active_record.default_timezone = :utc in config/enviroment.rb
- Login with administrative user, go Administration -> Users
- Last connection time is wrong
example
for me, I've logged in as admin in "01/01/2012 06:41 pm", my server zone is UTC+11, last connection time = "02/01/2012 05:43 am", admin user zone is UTC
value must be "01/01/2012 07:41 am"
solution?
Time.zone.now should be used instead of Time.now when user logged-in or autologged-in
Updated by Go MAEDA almost 10 years ago
- Category changed from Time tracking to Accounts / authentication
Updated by Go MAEDA almost 7 years ago
- Status changed from New to Confirmed
Confirmed the issue.
the user logged on at 12:47:49 JST +0900, but User.first.last_login_on returns 12:47:49 UTC +00:00.
Updated by Mizuki ISHIKAWA over 6 years ago
It could not be reproduced in the development environment. May be due to differences in environment.
However, I agree with changing Time.now to Time.zone.now
PostgreSQL: Docker container (TZ=JST)
Redmine app: Docker container (TZ=JST)
Run the following command in the Redmine app container:
$ date
2020/7/14 Tuesday 11:14:36 JST
$ rails console
> User.first.last_login_on
Tue, 14 Jul 2020 02:01:28 UTC +00:00
> Time.zone.now
Tue, 14 Jul 2020 02:07:28 UTC +00:00
$ psql
# show timezone;
TimeZone
------------
Asia/Tokyo
(1 row)
# select login, last_login_on from users;
login | last_login_on
-------+----------------------------
|
|
|
admin | 2020-07-14 02:01:28.928461
(4 rows)
Actions