hash user password on create

master
Joshua Herring 3 weeks ago
parent 162aff9c66
commit 115f4fdf6b

@ -2,6 +2,7 @@ package dbi
import ( import (
"context" "context"
"crypto/md5"
"database/sql" "database/sql"
"fmt" "fmt"
) )
@ -19,6 +20,9 @@ func CreateUser(conn *sql.Conn, user *User) error {
if user.APIKey == "" { if user.APIKey == "" {
user.APIKey = GenUUID() user.APIKey = GenUUID()
} }
if user.Password != "" {
user.Password := md5.Sum([]byte(user.Password))
}
_, err := conn.ExecContext(context.Background(), _, err := conn.ExecContext(context.Background(),
`INSERT INTO users (APIKey, FirstName, LastName, Password, Status, Username) `INSERT INTO users (APIKey, FirstName, LastName, Password, Status, Username)
VALUES (?, ?, ?, ?, ?, ?)`, VALUES (?, ?, ?, ?, ?, ?)`,

Loading…
Cancel
Save