WIP: Start implementing the internal auth
All checks were successful
ci/woodpecker/push/build Pipeline was successful

Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2026-05-05 22:56:56 +02:00
parent 4d73dbfd44
commit c52c3d1046
7 changed files with 51 additions and 63 deletions

View File

@@ -32,22 +32,24 @@ type JWT struct {
type AccountParams struct{}
type AccountData struct {
Username string
Password string
Email string
UUID string
}
func (c *AccountController) Create(ctx context.Context, data *AccountData) (string, error) {
log := logger.FromContext(ctx)
data.UUID = uuid.New().String()
passwordHash, err := hash.HashPassword(data.Password, int(c.HashCost))
if err != nil {
log.Error(err, "Couldn't crate the password hash")
return "", nil
}
query := "INSERT INTO users (uuid, username, email, password_hash) VALUES ($1, $2, $3, $4)"
if _, err := c.DB.Query(query, data.UUID, data.Username, data.Email, passwordHash); err != nil {
query := "INSERT INTO users (uuid, email, password_hash) VALUES ($1, $2, $3)"
if _, err := c.DB.Query(query, data.UUID, data.Email, passwordHash); err != nil {
log.Error(err, "Couldn't create a user in the database")
return "", err
}