Add environment variables and encryptor package
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user