Merge pull request #3554 from iamchating/master

FIX: #3520
This commit is contained in:
Eugene 2021-03-05 17:17:06 +03:00 committed by GitHub
commit bfeb353858
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,14 +5,26 @@ import * as keytar from 'keytar'
@Injectable({ providedIn: 'root' })
export class PasswordStorageService {
async savePassword (connection: SSHConnection, password: string): Promise<void> {
return keytar.setPassword(`ssh@${connection.host}`, connection.user, password)
let key = `ssh@${connection.host}`
if (connection.port) {
key = `ssh@${connection.host}:${connection.port}`
}
return keytar.setPassword(key, connection.user, password)
}
async deletePassword (connection: SSHConnection): Promise<void> {
await keytar.deletePassword(`ssh@${connection.host}`, connection.user)
let key = `ssh@${connection.host}`
if (connection.port) {
key = `ssh@${connection.host}:${connection.port}`
}
await keytar.deletePassword(key, connection.user)
}
async loadPassword (connection: SSHConnection): Promise<string|null> {
return keytar.getPassword(`ssh@${connection.host}`, connection.user)
let key = `ssh@${connection.host}`
if (connection.port) {
key = `ssh@${connection.host}:${connection.port}`
}
return keytar.getPassword(key, connection.user)
}
}