Skip to content

Commit 5399043

Browse files
Use updated password expiry API to calculate expiry warning
1 parent 1f18ce1 commit 5399043

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

TypeDBConsole.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class TypeDBConsole {
101101
Paths.get(System.getProperty("user.home"), ".typedb-console-transaction-repl-history").toAbsolutePath();
102102
private static final Logger LOG = LoggerFactory.getLogger(TypeDBConsole.class);
103103

104-
private static final int PASSWORD_EXPIRY_WARN_DAYS = 7;
104+
private static final Duration PASSWORD_EXPIRY_WARN = Duration.ofDays(7);
105105
private static final int ONE_HOUR_IN_MILLIS = 60 * 60 * 1000;
106106

107107
private final Printer printer;
@@ -464,9 +464,10 @@ private TypeDBClient createTypeDBClient(CLIOptions options) {
464464
String optCluster = options.cluster();
465465
if (optCluster != null) {
466466
client = TypeDB.clusterClient(set(optCluster.split(",")), createTypeDBCredential(options));
467-
Optional<Long> passwordExpiryDays = client.asCluster().users().get(options.username).passwordExpiryDays();
468-
if (passwordExpiryDays.isPresent() && passwordExpiryDays.get() <= PASSWORD_EXPIRY_WARN_DAYS) {
469-
printer.info("Your password will expire in " + passwordExpiryDays.get() + " days.");
467+
Optional<Duration> passwordExpiry = client.asCluster().users().get(options.username)
468+
.passwordExpirySeconds().map(Duration::ofSeconds);
469+
if (passwordExpiry.isPresent() && passwordExpiry.get().compareTo(PASSWORD_EXPIRY_WARN) < 0) {
470+
printer.info("Your password will expire in " + passwordExpiry.get().toHours() + " hours.");
470471
}
471472
} else {
472473
client = TypeDB.coreClient(TypeDB.DEFAULT_ADDRESS);

dependencies/vaticle/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ def vaticle_typedb_client_java():
3535
git_repository(
3636
name = "vaticle_typedb_client_java",
3737
remote = "https://github.com/vaticle/typedb-client-java",
38-
commit = "45fc692b6a398579e034fe720a49bba508c3099f", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_client_java
38+
commit = "302b2d8a44ee7be5f1d60d3d7b9e7d1bfa65cee7", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_client_java
3939
)

0 commit comments

Comments
 (0)