mirror of
https://github.com/Eugeny/tabby
synced 2024-11-16 01:38:07 +00:00
commit
bfeb353858
1 changed files with 15 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue