|
|
|
@ -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 (?, ?, ?, ?, ?, ?)`,
|
|
|
|
|