mirror of
https://github.com/Eugeny/tabby.git
synced 2025-01-07 03:10:41 +03:00
commit
bfeb353858
@ -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 New Issue
Block a user