Skip to content

Commit 235b9a3

Browse files
author
robdu
committed
Token should lazily load default value from configuration.
1 parent ff5215f commit 235b9a3

File tree

1 file changed

+5
-2
lines changed
  • core/main/java/com/codingchili/core/security

1 file changed

+5
-2
lines changed

core/main/java/com/codingchili/core/security/Token.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public class Token implements Serializable {
1717
private Map<String, Object> properties = new HashMap<>();
1818
private String domain = UUID.randomUUID().toString();
1919
private String key = "";
20-
private long expiry = Instant.now().getEpochSecond() +
21-
Configurations.security().getTokenttl();
20+
private Long expiry;
2221

2322
/**
2423
* Creates a new empty unverified token.
@@ -55,6 +54,10 @@ public Token setKey(String key) {
5554
* @return the time of expiry in epoch seconds.
5655
*/
5756
public long getExpiry() {
57+
if (expiry == null) {
58+
expiry = Instant.now().getEpochSecond() +
59+
Configurations.security().getTokenttl();
60+
}
5861
return expiry;
5962
}
6063

0 commit comments

Comments
 (0)