Add environment variables and encryptor package

This commit is contained in:
Archer Fox
2025-03-18 22:04:43 +03:00
parent 69be01a1db
commit e7b8eb5601
5 changed files with 48 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ package account
import (
"encoding/json"
"password/encrypter"
"password/output"
"strings"
"time"
@@ -28,10 +29,11 @@ type Vault struct {
type VaultWithDb struct {
Vault
db Db
db Db
enc encrypter.Encrypter
}
func NewVault(db Db) *VaultWithDb {
func NewVault(db Db, enc encrypter.Encrypter) *VaultWithDb {
file, err := db.Read()
if err != nil {
return &VaultWithDb{
@@ -39,7 +41,8 @@ func NewVault(db Db) *VaultWithDb {
Accounts: []Account{},
UpdatedAt: time.Now(),
},
db: db,
db: db,
enc: enc,
}
}
var vault Vault
@@ -51,12 +54,14 @@ func NewVault(db Db) *VaultWithDb {
Accounts: []Account{},
UpdatedAt: time.Now(),
},
db: db,
db: db,
enc: enc,
}
}
return &VaultWithDb{
Vault: vault,
db: db,
enc: enc,
}
}