Skip to content

Commit ec37969

Browse files
authored
Merge pull request #1911 from codefori/fix/auth_order
Auth update notices
2 parents 2c54d18 + d622639 commit ec37969

File tree

5 files changed

+126
-34
lines changed

5 files changed

+126
-34
lines changed

src/locale/ids/da.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const da: Locale = {
1515
'clearList': `$(trash) Nulstil liste`,
1616
'clearedList': `Nulstillede liste.`,
1717
'currentLibrary': `(aktuelle bibliotek)`,
18+
'current': `aktuelle`,
1819
'duplicate': 'Kopier',
1920
'save': 'Gem',
2021
'delete': 'Slet',
@@ -38,6 +39,10 @@ export const da: Locale = {
3839
'ask.overwrite':'{0} eksisterer allerede.\nVil du erstatte?',
3940
'skip':'Spring over',
4041
'skip_all':'Spring alle over',
42+
'password': 'Kodeord',
43+
'privateKey': 'Privat nøgle',
44+
'username': 'Brugernavn',
45+
'stored': `gemt`,
4146
// Sandbox:
4247
'sandbox.input.user.title': `Bruger for server`,
4348
'sandbox.input.user.prompt': `Indtast brugernavn for {0}`,
@@ -77,6 +82,20 @@ export const da: Locale = {
7782
'connectionBrowser.copyConnection.select.custom.variables': `Bruger variable`,
7883
'connectionBrowser.copyConnection.select.command.profiles': `Kommando profiler`,
7984
'connectionBrowser.copyConnection.select.connection.profiles': `Forbindelses profiler`,
85+
// Login page:
86+
'login.title.create': `Forbind til IBM i`,
87+
'login.title.edit': `Login Indstillinger: '{0}'`,
88+
'login.host': `Værtsnavn eller IP adresse`,
89+
'login.port': `Port (SSH)`,
90+
'login.authDecision': `Angiv enten kodeord eller privat nøgle - ikke begge dele.`,
91+
'login.removeAuth': `Fjern kodeord+nøgle`,
92+
'login.authRemoved': `Kodeord og privat nøgle er fjernet for '{0}'.`,
93+
'login.password.label': 'Angiv kun et kodeord hvis du ønsker at ændre det gemte eller oprette et nyt.',
94+
'login.password.updated': `Kodeord er opdateret og bruges for '{0}'.`,
95+
'login.savePassword': `Gem kodeord`,
96+
'login.privateKey.label': `Angiv kun en privat nøgle hvis du ønsker at opdatere den aktuelle eller indstille en ny.`,
97+
'login.privateKey.support': 'OpenSSH, RFC4716 og PPK formater understøttes.',
98+
'login.privateKey.updated': `Privat nøgle er opdateret og bruges for '{0}'.`,
8099
// helpView:
81100
'helpView.getStarted': `Dokumentation`,
82101
'helpView.officialForum': `Forum`,

src/locale/ids/en.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const en: Locale = {
1515
'clearList': `$(trash) Clear list`,
1616
'clearedList': `Cleared list.`,
1717
'currentLibrary': `(current library)`,
18+
'current': `current`,
1819
'duplicate': 'Duplicate',
1920
'save': 'Save',
2021
'delete': 'Delete',
@@ -38,6 +39,10 @@ export const en: Locale = {
3839
'ask.overwrite':'{0} already exists.\nDo you want to replace it?',
3940
'skip':'Skip',
4041
'skip_all':'Skip all',
42+
'password': 'Password',
43+
'privateKey': 'Private Key',
44+
'username': 'Username',
45+
'stored': `stored`,
4146
// Sandbox:
4247
'sandbox.input.user.title': `User for server`,
4348
'sandbox.input.user.prompt': `Enter username for {0}`,
@@ -77,6 +82,20 @@ export const en: Locale = {
7782
'connectionBrowser.copyConnection.select.custom.variables': `Custom variables`,
7883
'connectionBrowser.copyConnection.select.command.profiles': `Command profiles`,
7984
'connectionBrowser.copyConnection.select.connection.profiles': `Connection profiles`,
85+
// Login page:
86+
'login.title.create': `Connect to IBM i`,
87+
'login.title.edit': `Login Settings: '{0}'`,
88+
'login.host': `Host or IP Address`,
89+
'login.port': `Port (SSH)`,
90+
'login.authDecision': `Only provide either the password or a private key - not both.`,
91+
'login.removeAuth': `Remove auth methods`,
92+
'login.authRemoved': `Authentication methods removed for '{0}'.`,
93+
'login.password.label': 'Only provide a password if you want to update an existing one or set a new one.',
94+
'login.password.updated': `Password updated and will be used for '{0}'.`,
95+
'login.savePassword': `Save Password`,
96+
'login.privateKey.label': `Only provide a private key if you want to update from the existing one or set one.`,
97+
'login.privateKey.support': 'OpenSSH, RFC4716 and PPK formats are supported.',
98+
'login.privateKey.updated': `Private key updated and will be used for '{0}'.`,
8099
// helpView:
81100
'helpView.getStarted': `Get started`,
82101
'helpView.officialForum': `Open official Forum`,
@@ -131,7 +150,7 @@ export const en: Locale = {
131150
'ifsBrowser.searchIFS.placeholder': `Enter search term or select one of the previous search terms.`,
132151
'ifsBrowser.searchIFS.placeholder2': `Enter search term.`,
133152
'ifsBrowser.searchIFS.noGrep': `grep must be installed on the remote system for the IFS search.`,
134-
'ifsBrowser.downloadStreamfile.downloading':'Downloading',
153+
'ifsBrowser.downloadStreamfile.downloading':'Downloading',
135154
'ifsBrowser.downloadStreamfile.complete': `Download complete`,
136155
'ifsBrowser.downloadStreamfile.errorMessage': `Error downloading file(s): {0}`,
137156
'ifsBrowser.getChildren.errorMessage': `Error loading objects.`,

src/locale/ids/fr.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const fr: Locale = {
1515
'clearList': `$(trash) Effacer liste`,
1616
'clearedList': `Liste effacée.`,
1717
'currentLibrary': `(bibliothèque en cours)`,
18+
'current': `actuelle`,
1819
'duplicate': 'Dupliquer',
1920
'save': 'Enregistrer',
2021
'delete': 'Supprimer',
@@ -38,6 +39,10 @@ export const fr: Locale = {
3839
'ask.overwrite':'{0} existe déjà.\nVoulez-vous le remplacer?',
3940
'skip':'Ignorer',
4041
'skip_all':'Ignorer tout',
42+
'password': 'Mot de passe',
43+
'privateKey': 'Clé privée',
44+
'username': 'Utilisateur',
45+
'stored': `enregistré`,
4146
// Sandbox:
4247
'sandbox.input.user.title': `Nom d'utilisateur`,
4348
'sandbox.input.user.prompt': `Entrez le nom d'utilisateur pour {0}`,
@@ -77,6 +82,20 @@ export const fr: Locale = {
7782
'connectionBrowser.copyConnection.select.custom.variables': `Variables personnalisées`,
7883
'connectionBrowser.copyConnection.select.command.profiles': `Profiles de commande`,
7984
'connectionBrowser.copyConnection.select.connection.profiles': `Profile de connection`,
85+
// Login page:
86+
'login.title.create': `Connect to IBM i`,
87+
'login.title.edit': `paramètres d'authentification: '{0}'`,
88+
'login.host': `Nom d'Hôte ou Adresse IP`,
89+
'login.port': `Port (SSH)`,
90+
'login.authDecision': `Renseignez soit le mot de passe, soit la clé privée - pas les deux.`,
91+
'login.removeAuth': `Supprimer l'authentification`,
92+
'login.authRemoved': `Authentification supprimée pour '{0}'.`,
93+
'login.password.label': 'Rensignez un mot de passe seulement si vous souhaitez le changer.',
94+
'login.password.updated': `Mot de passe mis à jour et utilisé pour se connecter à '{0}'.`,
95+
'login.savePassword': `Sauvegarder Mot de passe`,
96+
'login.privateKey.label': `Sélectionnez une clé privée seulement si vous souhaitez en changer.`,
97+
'login.privateKey.support': 'Les formats OpenSSH, RFC4716 et PPK sont supportés.',
98+
'login.privateKey.updated': `Clé privée mise à jour et utilisée pour se connecter à '{0}'.`,
8099
// helpView:
81100
'helpView.getStarted': `Pour commencer`,
82101
'helpView.officialForum': `Forum officiel`,

src/webviews/login/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CustomUI, Section } from "../../api/CustomUI";
44
import IBMi from "../../api/IBMi";
55
import { disconnect, instance } from "../../instantiate";
66
import { ConnectionData } from '../../typings';
7+
import { t } from "../../locale";
78

89
type NewLoginSettings = ConnectionData & {
910
savePassword: boolean
@@ -28,13 +29,13 @@ export class Login {
2829

2930
const connectionTab = new Section()
3031
.addInput(`name`, `Connection Name`, undefined, { minlength: 1 })
31-
.addInput(`host`, `Host or IP Address`, undefined, { minlength: 1 })
32-
.addInput(`port`, `Port (SSH)`, ``, { default: `22`, minlength: 1, maxlength: 5, regexTest: `^\\d+$` })
33-
.addInput(`username`, `Username`, undefined, { minlength: 1, maxlength: 10 })
34-
.addParagraph(`Only provide either the password or a private key - not both.`)
35-
.addPassword(`password`, `Password`)
36-
.addCheckbox(`savePassword`, `Save Password`)
37-
.addFile(`privateKeyPath`, `Private Key`, `OpenSSH, RFC4716, or PPK formats are supported.`);
32+
.addInput(`host`, t(`login.host`), undefined, { minlength: 1 })
33+
.addInput(`port`, t(`login.port`), ``, { default: `22`, minlength: 1, maxlength: 5, regexTest: `^\\d+$` })
34+
.addInput(`username`, t(`username`), undefined, { minlength: 1, maxlength: 10 })
35+
.addParagraph(t(`login.authDecision`))
36+
.addPassword(`password`, t(`password`))
37+
.addCheckbox(`savePassword`, t(`login.savePassword`))
38+
.addFile(`privateKeyPath`, t(`privateKey`), t(`login.privateKey.support`));
3839

3940
const tempTab = new Section()
4041
.addInput(`tempLibrary`, `Temporary library`, `Temporary library. Cannot be QTEMP.`, { default: `ILEDITOR`, minlength: 1, maxlength: 10 })

src/webviews/settings/index.ts

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isManaged } from "../../api/debug";
77
import * as certificates from "../../api/debug/certificates";
88
import { instance } from "../../instantiate";
99
import { ConnectionData, Server } from '../../typings';
10+
import { t } from "../../locale";
1011

1112
const ENCODINGS = [`37`, `256`, `273`, `277`, `278`, `280`, `284`, `285`, `297`, `500`, `871`, `870`, `905`, `880`, `420`, `875`, `424`, `1026`, `290`, `win37`, `win256`, `win273`, `win277`, `win278`, `win280`, `win284`, `win285`, `win297`, `win500`, `win871`, `win870`, `win905`, `win880`, `win420`, `win875`, `win424`, `win1026`];
1213

@@ -311,44 +312,77 @@ export class SettingsUI {
311312
if (connections) {
312313
const connectionIdx = connections.findIndex(item => item.name === name);
313314
let connection = connections[connectionIdx];
315+
const storedPassword = await context.secrets.get(`${name}_password`);
314316

315317
const page = await new CustomUI()
316-
.addInput(`host`, `Host or IP Address`, undefined, { default: connection.host, minlength: 1 })
317-
.addInput(`port`, `Port (SSH)`, undefined, { default: String(connection.port), minlength: 1, maxlength: 5, regexTest: `^\\d+$` })
318-
.addInput(`username`, `Username`, undefined, { default: connection.username, minlength: 1 })
319-
.addParagraph(`Only provide either the password or a private key - not both.`)
320-
.addPassword(`password`, `Password`, `Only provide a password if you want to update an existing one or set a new one.`)
321-
.addFile(`privateKeyPath`, `Private Key${connection.privateKeyPath ? ` (current: ${connection.privateKeyPath})` : ``}`, `Only provide a private key if you want to update from the existing one or set one. OpenSSH, RFC4716, or PPK formats are supported.`)
322-
.addButtons({ id: `submitButton`, label: `Save`, requiresValidation: true })
323-
.loadPage<LoginSettings>(`Login Settings: ${name}`);
318+
.addInput(`host`, t(`login.host`), undefined, { default: connection.host, minlength: 1 })
319+
.addInput(`port`, t(`login.port`), undefined, { default: String(connection.port), minlength: 1, maxlength: 5, regexTest: `^\\d+$` })
320+
.addInput(`username`, t(`username`), undefined, { default: connection.username, minlength: 1 })
321+
.addParagraph(t(`login.authDecision`))
322+
.addPassword(`password`, `${t(`password`)}${storedPassword ? ` (${t(`stored`)})` : ``}`, t(`login.password.label`))
323+
.addFile(`privateKeyPath`, `${t(`privateKey`)}${connection.privateKeyPath ? ` (${t(`current`)}: ${connection.privateKeyPath})` : ``}`, t(`login.privateKey.label`) + ' ' + t(`login.privateKey.support`))
324+
.addButtons(
325+
{ id: `submitButton`, label: t(`save`), requiresValidation: true },
326+
{ id: `removeAuth`, label: t(`login.removeAuth`) }
327+
)
328+
.loadPage<LoginSettings>(t(`login.title.edit`, name));
324329

325330
if (page && page.data) {
326331
page.panel.dispose();
327332

328333
const data = page.data;
329-
if (!data.privateKeyPath?.trim()) {
330-
if (connection.privateKeyPath?.trim()) {
331-
data.privateKeyPath = connection.privateKeyPath;
334+
335+
let doUpdate = false;
336+
337+
const chosenButton = data.buttons as "submitButton" | "removeAuth";
338+
339+
switch (chosenButton) {
340+
case `submitButton`:
341+
if (data.password) {
342+
// New password was entered, so store the password
343+
// and remove the private key path from the data
344+
await context.secrets.store(`${name}_password`, `${data.password}`);
345+
data.privateKeyPath = undefined;
346+
347+
vscode.window.showInformationMessage(t(`login.password.updated`, name));
348+
349+
doUpdate = true;
350+
351+
} else {
352+
// If no password was entered, but a keypath exists
353+
// then remove the password from the data and
354+
// use the keypath instead
355+
if (data.privateKeyPath?.trim()) {
356+
await context.secrets.delete(`${name}_password`);
357+
358+
vscode.window.showInformationMessage(t(`login.privateKey.updated`, name));
359+
360+
doUpdate = true;
361+
}
362+
}
363+
break;
364+
365+
case `removeAuth`:
332366
await context.secrets.delete(`${name}_password`);
333-
}
334-
else {
335-
delete data.privateKeyPath;
336-
}
337-
}
367+
data.password = undefined;
368+
data.privateKeyPath = undefined;
369+
370+
vscode.window.showInformationMessage(t(`login.authRemoved`, name));
338371

339-
if (data.password && !data.privateKeyPath) {
340-
await context.secrets.delete(`${name}_password`);
341-
await context.secrets.store(`${name}_password`, `${data.password}`);
342-
delete data.privateKeyPath;
372+
doUpdate = true;
373+
break;
343374
}
344375

345-
//Fix values before assigning the data
346-
data.port = Number(data.port);
347-
delete data.password;
348-
delete data.buttons;
349376

350-
connections[connectionIdx] = Object.assign(connection, data);
351-
await GlobalConfiguration.set(`connections`, connections);
377+
if (doUpdate) {
378+
//Fix values before assigning the data
379+
data.port = Number(data.port);
380+
delete data.password;
381+
delete data.buttons;
382+
383+
connections[connectionIdx] = Object.assign(connection, data);
384+
await GlobalConfiguration.set(`connections`, connections);
385+
}
352386
}
353387
}
354388
}

0 commit comments

Comments
 (0)