From 115f4fdf6b1bafb0d6bd8f3f876097cb25e6d0c2 Mon Sep 17 00:00:00 2001 From: Joshua Herring Date: Wed, 27 May 2026 15:32:32 -0400 Subject: [PATCH] hash user password on create --- dbi/user.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dbi/user.go b/dbi/user.go index 8408747..78a226d 100644 --- a/dbi/user.go +++ b/dbi/user.go @@ -2,6 +2,7 @@ package dbi import ( "context" + "crypto/md5" "database/sql" "fmt" ) @@ -19,6 +20,9 @@ func CreateUser(conn *sql.Conn, user *User) error { if user.APIKey == "" { user.APIKey = GenUUID() } + if user.Password != "" { + user.Password := md5.Sum([]byte(user.Password)) + } _, err := conn.ExecContext(context.Background(), `INSERT INTO users (APIKey, FirstName, LastName, Password, Status, Username) VALUES (?, ?, ?, ?, ?, ?)`,