in src/models/connectionCredentials.ts [81:120]
public static ensureRequiredPropertiesSet(
credentials: IConnectionCredentials,
isProfile: boolean,
isPasswordRequired: boolean,
wasPasswordEmptyInConfigFile: boolean,
prompter: IPrompter,
connectionStore: ConnectionStore,
defaultProfileValues?: IConnectionCredentials): Promise<IConnectionCredentials> {
let questions: IQuestion[] = ConnectionCredentials.getRequiredCredentialValuesQuestions(credentials, false, isPasswordRequired, defaultProfileValues);
let unprocessedCredentials: IConnectionCredentials = Object.assign({}, credentials);
return prompter.prompt(questions).then(answers => {
if (answers) {
if (isProfile) {
let profile: IConnectionProfile = <IConnectionProfile>credentials;
// If this is a profile, and the user has set save password to true and either
// stored the password in the config file or purposefully set an empty password,
// then transfer the password to the credential store
if (profile.savePassword && (!wasPasswordEmptyInConfigFile || profile.emptyPasswordInput)) {
// Remove profile, then save profile without plain text password
connectionStore.removeProfile(profile).then(() => {
connectionStore.saveProfile(profile);
});
// Or, if the user answered any additional questions for the profile, be sure to save it
} else if (profile.authenticationType !== unprocessedCredentials.authenticationType ||
profile.savePassword !== (<IConnectionProfile>unprocessedCredentials).savePassword ||
profile.password !== unprocessedCredentials.password) {
connectionStore.removeProfile(profile).then(() => {
connectionStore.saveProfile(profile);
});
}
}
return credentials;
} else {
return undefined;
}
});
}