Skip to content

Commit 1f18ce1

Browse files
author
James Williams
authored
Prompt a re-login when users change their own passwords (#201)
## What is the goal of this PR? Console now quits upon a user changing their own password, rather than having a user be left in a session with invalid credentials (which they will only discover on running subsequent commands). ## What are the changes implemented in this PR? We've added checks to determine whether password sets and updates were successful, and if so, prompt the user to log in again before quitting.
1 parent 8080d5a commit 1f18ce1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

TypeDBConsole.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,23 @@ private void runREPLMode(CLIOptions options) {
199199
runUserCreate(client, command.asUserCreate().user(), command.asUserCreate().password());
200200
} else if (command.isUserPasswordUpdate()) {
201201
REPLCommand.User.PasswordUpdate userPasswordUpdate = command.asUserPasswordUpdate();
202-
runUserPasswordUpdate(client,
202+
boolean passwordUpdateSuccessful = runUserPasswordUpdate(client,
203203
options.username,
204204
userPasswordUpdate.passwordOld(),
205205
userPasswordUpdate.passwordNew());
206+
if (passwordUpdateSuccessful) {
207+
printer.info("Please login again with your updated password.");
208+
break;
209+
}
206210
} else if (command.isUserPasswordSet()) {
207211
REPLCommand.User.PasswordSet userPasswordSet = command.asUserPasswordSet();
208-
runUserPasswordSet(client,
212+
boolean passwordSetSuccessful = runUserPasswordSet(client,
209213
userPasswordSet.user(),
210214
userPasswordSet.password());
215+
if (passwordSetSuccessful && userPasswordSet.user().equals(client.asCluster().user().username())) {
216+
printer.info("Please login again with your updated password.");
217+
break;
218+
}
211219
} else if (command.isUserDelete()) {
212220
runUserDelete(client, command.asUserDelete().user());
213221
} else if (command.isDatabaseList()) {
@@ -526,7 +534,7 @@ private boolean runUserPasswordUpdate(TypeDBClient client, String username, Stri
526534
}
527535
TypeDBClient.Cluster clientCluster = client.asCluster();
528536
clientCluster.users().get(username).passwordUpdate(passwordOld, passwordNew);
529-
printer.info("Updated password for user '" + username + "'");
537+
printer.info("Updated password for user '" + username + "'.");
530538
return true;
531539
} catch (TypeDBClientException e) {
532540
printer.error(e.getMessage());

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-
tag = "2.16.1", # sync-marker: do not remove this comment, this is used for sync-dependencies by @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
3939
)

0 commit comments

Comments
 (0)