summaryrefslogtreecommitdiff
path: root/pkg/database/accounts.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-11-17 00:05:22 +0100
committerJulien Dessaux2024-12-17 23:19:18 +0100
commit25ed1188ed970a19675befef12afe68045565c4a (patch)
tree5cfc55047d833400028fb69a7f069f5cedecaacd /pkg/database/accounts.go
parentfix(tfstated): hash passwords instead of relying on the database encryption key (diff)
downloadtfstated-25ed1188ed970a19675befef12afe68045565c4a.tar.gz
tfstated-25ed1188ed970a19675befef12afe68045565c4a.tar.bz2
tfstated-25ed1188ed970a19675befef12afe68045565c4a.zip
chore(tfstated): refactor helpers to their own package
Diffstat (limited to 'pkg/database/accounts.go')
-rw-r--r--pkg/database/accounts.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/database/accounts.go b/pkg/database/accounts.go
index 6400d5a..f506155 100644
--- a/pkg/database/accounts.go
+++ b/pkg/database/accounts.go
@@ -7,6 +7,7 @@ import (
"log/slog"
"time"
+ "git.adyxax.org/adyxax/tfstated/pkg/helpers"
"git.adyxax.org/adyxax/tfstated/pkg/model"
"go.n16f.net/uuid"
)
@@ -69,8 +70,8 @@ func (db *DB) InitAdminAccount() error {
if err = password.Generate(uuid.V4); err != nil {
return fmt.Errorf("failed to generate initial admin password: %w", err)
}
- salt := model.GenerateSalt()
- hash := model.HashPassword(password.String(), salt)
+ salt := helpers.GenerateSalt()
+ hash := helpers.HashPassword(password.String(), salt)
if _, err = tx.ExecContext(db.ctx,
`INSERT INTO accounts(username, salt, password_hash, is_admin)
VALUES ("admin", :salt, :hash, TRUE)