Skip to content

Commit

Permalink
feat(cli): include username in password prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
thetric committed Apr 5, 2017
1 parent 1db19e0 commit 28bb0a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ final class ExistingConfigCliController {
}

private void promptForPassword(IliasService iliasService, UserPreferences prefs) {
while (true) {
try {
String passwordPrompt = resourceBundle.getString('login.credentials.password')
String password = consoleService.readPassword('ilias.credentials.password', passwordPrompt)
iliasService.login(new LoginCredentials(prefs.userName, password))
return
} catch (IliasAuthenticationException authEx) {
log.catching(Level.DEBUG, authEx)
}
try {
String passwordPrompt = resourceBundle.getString('login.credentials.password')
String namePwPrompt = String.format(passwordPrompt, prefs.userName)
String password = consoleService.readPassword('ilias.credentials.password', namePwPrompt)
iliasService.login(new LoginCredentials(prefs.userName, password))
} catch (IliasAuthenticationException authEx) {
log.catching(Level.DEBUG, authEx)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,10 @@ class SetupController {
}

private IliasService createIliasServiceFromUserUrl() {
while (true) {
String serverUrl = promptForServerUrl()
try {
IliasService iliasService = iliasProvider.apply(serverUrl)
prefs.iliasServerURL = serverUrl
return iliasService
} catch (RuntimeException e) {
log.catching(e)
}
}
String serverUrl = promptForServerUrl()
IliasService iliasService = iliasProvider.apply(serverUrl)
prefs.iliasServerURL = serverUrl
return iliasService
}

private promptForServerUrl() {
Expand All @@ -56,7 +50,8 @@ class SetupController {
String usernamePrompt = resourceBundle.getString('login.credentials.username')
String username = consoleService.readLine('ilias.credentials.username', usernamePrompt)
String passwordPrompt = resourceBundle.getString('login.credentials.password')
String password = consoleService.readPassword('ilias.credentials.password', passwordPrompt)
String namePwPrompt = String.format(passwordPrompt, prefs.userName)
String password = consoleService.readPassword('ilias.credentials.password', namePwPrompt)

iliasService.login(new LoginCredentials(username, password))
prefs.userName = username
Expand Down
2 changes: 1 addition & 1 deletion ui/cli/src/main/resources/ilias-cli.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ args.sync.max-size=size limit in MiB per file download (exclusive)
args.sync.max-size.negative=max download size per item must not be negative:

login.credentials.username = Username
login.credentials.password = Password
login.credentials.password = %s's password
login.successful = Login succeeded
login.error = Login failed
Expand Down
2 changes: 1 addition & 1 deletion ui/cli/src/main/resources/ilias-cli_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ args.sync.max-size=maximale Größe der herunterzuladenen Datei in MiB (exklusiv
args.sync.max-size.negative=Downloadlimit pro Datei darf nicht negativ sein:

login.credentials.username = Benutzername
login.credentials.password = Passwort
login.credentials.password = Passwort von %s
login.successful = Login erfolgreich
login.error=Login fehlgeschlagen

Expand Down

0 comments on commit 28bb0a2

Please sign in to comment.