fix: ignore system user in users query & add full name to user in install route

This commit is contained in:
Jordan Knott 2020-07-16 21:57:02 -05:00
parent 45a92636cb
commit d3f29134e0
3 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,7 @@
SELECT * FROM user_account WHERE user_id = $1; SELECT * FROM user_account WHERE user_id = $1;
-- name: GetAllUserAccounts :many -- name: GetAllUserAccounts :many
SELECT * FROM user_account; SELECT * FROM user_account WHERE username != 'system';
-- name: GetUserAccountByUsername :one -- name: GetUserAccountByUsername :one
SELECT * FROM user_account WHERE username = $1; SELECT * FROM user_account WHERE username = $1;

View File

@ -62,7 +62,7 @@ func (q *Queries) DeleteUserAccountByID(ctx context.Context, userID uuid.UUID) e
} }
const getAllUserAccounts = `-- name: GetAllUserAccounts :many 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) { func (q *Queries) GetAllUserAccounts(ctx context.Context) ([]UserAccount, error) {

View File

@ -218,6 +218,7 @@ func (h *CitadelHandler) InstallHandler(w http.ResponseWriter, r *http.Request)
createdAt := time.Now().UTC() createdAt := time.Now().UTC()
hashedPwd, err := bcrypt.GenerateFromPassword([]byte(requestData.User.Password), 14) hashedPwd, err := bcrypt.GenerateFromPassword([]byte(requestData.User.Password), 14)
user, err := h.repo.CreateUserAccount(r.Context(), db.CreateUserAccountParams{ user, err := h.repo.CreateUserAccount(r.Context(), db.CreateUserAccountParams{
FullName: requestData.User.FullName,
Username: requestData.User.Username, Username: requestData.User.Username,
Initials: requestData.User.Initials, Initials: requestData.User.Initials,
Email: requestData.User.Email, Email: requestData.User.Email,