Add user account roles

This commit is contained in:
Eli Ribble 2026-02-18 07:02:36 +00:00
parent b4817546df
commit 7ea66dc02e
No known key found for this signature in database
10 changed files with 188 additions and 12 deletions

View file

@ -22,7 +22,7 @@ import (
//go:embed user_by_username.bob.sql
var formattedQueries_user_by_username string
var userByUsernameSQL = formattedQueries_user_by_username[152:780]
var userByUsernameSQL = formattedQueries_user_by_username[152:806]
type UserByUsernameQuery = orm.ModQuery[*dialect.SelectQuery, userByUsername, UserByUsernameRow, []UserByUsernameRow, userByUsernameTransformer]
@ -55,6 +55,7 @@ func UserByUsername(Username string) *UserByUsernameQuery {
row.ScheduleScanByIndex(9, &t.Username)
row.ScheduleScanByIndex(10, &t.PasswordHashType)
row.ScheduleScanByIndex(11, &t.PasswordHash)
row.ScheduleScanByIndex(12, &t.Role)
return &t, nil
}, func(v any) (UserByUsernameRow, error) {
return *(v.(*UserByUsernameRow)), nil
@ -62,9 +63,9 @@ func UserByUsername(Username string) *UserByUsernameQuery {
},
},
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
q.AppendSelect(expressionTypArgs.subExpr(7, 551))
q.SetTable(expressionTypArgs.subExpr(557, 569))
q.AppendWhere(expressionTypArgs.subExpr(577, 628))
q.AppendSelect(expressionTypArgs.subExpr(7, 577))
q.SetTable(expressionTypArgs.subExpr(583, 595))
q.AppendWhere(expressionTypArgs.subExpr(603, 654))
}),
}
}
@ -82,6 +83,7 @@ type UserByUsernameRow = struct {
Username string `db:"username"`
PasswordHashType enums.Hashtype `db:"password_hash_type"`
PasswordHash string `db:"password_hash"`
Role enums.Userrole `db:"role"`
}
type userByUsernameTransformer = bob.SliceTransformer[UserByUsernameRow, []UserByUsernameRow]
@ -94,8 +96,8 @@ func (o userByUsername) args() iter.Seq[orm.ArgWithPosition] {
return func(yield func(arg orm.ArgWithPosition) bool) {
if !yield(orm.ArgWithPosition{
Name: "username",
Start: 588,
Stop: 590,
Start: 614,
Stop: 616,
Expression: o.Username,
}) {
return

View file

@ -2,6 +2,6 @@
-- This file is meant to be re-generated in place and/or deleted at any time.
-- UserByUsername
SELECT "user_"."id" AS "id", "user_"."arcgis_access_token" AS "arcgis_access_token", "user_"."arcgis_license" AS "arcgis_license", "user_"."arcgis_refresh_token" AS "arcgis_refresh_token", "user_"."arcgis_refresh_token_expires" AS "arcgis_refresh_token_expires", "user_"."arcgis_role" AS "arcgis_role", "user_"."display_name" AS "display_name", "user_"."email" AS "email", "user_"."organization_id" AS "organization_id", "user_"."username" AS "username", "user_"."password_hash_type" AS "password_hash_type", "user_"."password_hash" AS "password_hash" FROM public.user_ WHERE
SELECT "user_"."id" AS "id", "user_"."arcgis_access_token" AS "arcgis_access_token", "user_"."arcgis_license" AS "arcgis_license", "user_"."arcgis_refresh_token" AS "arcgis_refresh_token", "user_"."arcgis_refresh_token_expires" AS "arcgis_refresh_token_expires", "user_"."arcgis_role" AS "arcgis_role", "user_"."display_name" AS "display_name", "user_"."email" AS "email", "user_"."organization_id" AS "organization_id", "user_"."username" AS "username", "user_"."password_hash_type" AS "password_hash_type", "user_"."password_hash" AS "password_hash", "user_"."role" AS "role" FROM public.user_ WHERE
username = $1 AND
password_hash_type = 'bcrypt-14';