aboutsummaryrefslogtreecommitdiffstats
path: root/internal/store/users.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/store/users.go')
-rw-r--r--internal/store/users.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/store/users.go b/internal/store/users.go
index 2910888..3ea9bdb 100644
--- a/internal/store/users.go
+++ b/internal/store/users.go
@@ -47,6 +47,11 @@ func (s *Store) UserByUsername(ctx context.Context, username string) (*User, err
return scanUser(s.db.QueryRow(ctx, `SELECT `+userCols+` FROM users WHERE username=$1`, username))
}
+// FirstSuperadmin returns the oldest superadmin account.
+func (s *Store) FirstSuperadmin(ctx context.Context) (*User, error) {
+ return scanUser(s.db.QueryRow(ctx, `SELECT `+userCols+` FROM users WHERE role=$1 ORDER BY id LIMIT 1`, RoleSuperadmin))
+}
+
func (s *Store) CountSuperadmins(ctx context.Context) (int, error) {
var n int
err := s.db.QueryRow(ctx, `SELECT count(*) FROM users WHERE role=$1`, RoleSuperadmin).Scan(&n)