Skip to content

Commit

Permalink
feat: host enctypt too
Browse files Browse the repository at this point in the history
  • Loading branch information
huangxingguang authored and starxg committed Jun 19, 2021
1 parent b8a4402 commit 6a61647
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/SettingsTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class SyncConfigSettingsTabComponent implements OnInit {
try {
if (conn.auth !== null && conn.auth.encryptType && conn.auth.encryptType === 'AES') {
conn.auth.password = this.aesDecrypt(conn.auth.password, token);
conn.host = this.aesDecrypt(conn.host, token);
}
await this.passwordStorage.savePassword(conn)
} catch (error) {
Expand All @@ -147,7 +148,7 @@ export class SyncConfigSettingsTabComponent implements OnInit {
return;
}

const encryption = this.config.store.syncConfig.encryption;
const isEncrypt = this.config.store.syncConfig.encryption === true;

const infos = [];
for (const connect of connections) {
Expand All @@ -156,10 +157,10 @@ export class SyncConfigSettingsTabComponent implements OnInit {
const pwd = await this.passwordStorage.loadPassword({ host, port, user });
if (!pwd) continue;
infos.push({
host, port, user,
host: isEncrypt ? this.aesDecrypt(host, token) : pwd, port, user,
auth: {
password: encryption === true ? this.aesEncrypt(pwd.toString(), token) : pwd,
encryptType: encryption === true ? 'AES' : 'NONE'
password: isEncrypt ? this.aesEncrypt(pwd.toString(), token) : pwd,
encryptType: isEncrypt ? 'AES' : 'NONE'
}
});
} catch (error) {
Expand Down

0 comments on commit 6a61647

Please sign in to comment.