You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/modules/security/pages/authentication.adoc
+48-1Lines changed: 48 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,10 @@ You can customize the prefix for resource role authorities using the standard Sp
28
28
29
29
Similarly, you can adjust the prefix for row-level role authorities using the `jmix.security.default-row-level-role-prefix` application property.
30
30
====
31
-
* `getLocale()` and `getTimeZone()` return the locale and time zone of the current user.
31
+
32
+
* `getLocale()` returns the locale of the current user.
33
+
34
+
* `getTimeZone()` returns the time zone of the current user. The <<time-zones,next section>> explains how the user time zone is determined and how it is used by the framework.
32
35
33
36
* `isSet()` returns `true` if the current execution thread is authenticated, that is contains information about the user. If it's not, `getUser()`, `getLocale()` and `getTimeZone()` methods described above will throw the `IllegalStateException`.
For example, you can use `DelegatingSecurityContextRunnable` to propagate authentication to new threads as described in {spring-security-doc}/servlet/integrations/concurrency.html[Spring Security documentation^].
47
50
====
48
51
52
+
[[time-zones]]
53
+
=== Using Time Zones
54
+
55
+
Jmix automatically converts values in UI components between server and user time zones for entity attributes of the following types:
56
+
57
+
* `OffsetDateTime`
58
+
* `java.util.Date` with `@Temporal(TemporalType.TIMESTAMP)`, which corresponds to the `DateTime` attribute type in Studio.
59
+
60
+
Below we explain how to specify the user and server time zones.
61
+
62
+
By default, the `User` entity implements the `HasTimeZone` interface with two methods:
63
+
64
+
* `getTimeZoneId()` is implemented in the `User` entity and returns a time zone set for the user in the database.
65
+
66
+
* `isAutoTimeZone()` method returns `false` by default for all users. You can implement this method in the `User` entity and return `true` for all users, or map it to a database column as it is done for `getTimeZoneId()` to have different values for different users.
67
+
68
+
The time zone of the current user returned by `CurrentAuthentication.getTimeZone()` is determined in the following order:
69
+
70
+
* A non-empty value returned by the `User.getTimeZoneId()` method is used to construct the `TimeZone` object.
71
+
72
+
* If the `User.isAutoTimeZone()` method returns `true`, the framework tries to obtain the time zone from the user's web browser through a `DeviceTimeZoneProvider` implementation.
73
+
74
+
* If both previous steps were unsuccessful, the server default time zone is used.
75
+
76
+
The server time zone is defined by the server operating system. You can set it explicitly using the `user.timezone` Java system property or `TimeZone` class. For example:
0 commit comments