From d3f29134e05879bd3b651b1c97f27ba3daa1603e Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Thu, 16 Jul 2020 21:57:02 -0500 Subject: [PATCH] fix: ignore system user in users query & add full name to user in install route --- internal/db/query/user_accounts.sql | 2 +- internal/db/user_accounts.sql.go | 2 +- internal/route/auth.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/db/query/user_accounts.sql b/internal/db/query/user_accounts.sql index dc42312..c65ef91 100644 --- a/internal/db/query/user_accounts.sql +++ b/internal/db/query/user_accounts.sql @@ -2,7 +2,7 @@ SELECT * FROM user_account WHERE user_id = $1; -- name: GetAllUserAccounts :many -SELECT * FROM user_account; +SELECT * FROM user_account WHERE username != 'system'; -- name: GetUserAccountByUsername :one SELECT * FROM user_account WHERE username = $1; diff --git a/internal/db/user_accounts.sql.go b/internal/db/user_accounts.sql.go index 9b8600c..6bfa280 100644 --- a/internal/db/user_accounts.sql.go +++ b/internal/db/user_accounts.sql.go @@ -62,7 +62,7 @@ func (q *Queries) DeleteUserAccountByID(ctx context.Context, userID uuid.UUID) e } const getAllUserAccounts = `-- name: GetAllUserAccounts :many -SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code FROM user_account +SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code FROM user_account WHERE username != 'system' ` func (q *Queries) GetAllUserAccounts(ctx context.Context) ([]UserAccount, error) { diff --git a/internal/route/auth.go b/internal/route/auth.go index bda5bad..e85347e 100644 --- a/internal/route/auth.go +++ b/internal/route/auth.go @@ -218,6 +218,7 @@ func (h *CitadelHandler) InstallHandler(w http.ResponseWriter, r *http.Request) createdAt := time.Now().UTC() hashedPwd, err := bcrypt.GenerateFromPassword([]byte(requestData.User.Password), 14) user, err := h.repo.CreateUserAccount(r.Context(), db.CreateUserAccountParams{ + FullName: requestData.User.FullName, Username: requestData.User.Username, Initials: requestData.User.Initials, Email: requestData.User.Email,