mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-05 02:50:00 +00:00
commit
bfeb353858
@ -5,14 +5,26 @@ import * as keytar from 'keytar'
|
|||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class PasswordStorageService {
|
export class PasswordStorageService {
|
||||||
async savePassword (connection: SSHConnection, password: string): Promise<void> {
|
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> {
|
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> {
|
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…
x
Reference in New Issue
Block a user