MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / GetAdminUser

Method GetAdminUser

internal/store/postgres/users.go:694–706  ·  view source on GitHub ↗

GetAdminUser 返回第一个 is_admin=true 的用户。

()

Source from the content-addressed store, hash-verified

692
693// GetAdminUser 返回第一个 is_admin=true 的用户。
694func (s *UserStore) GetAdminUser() (users.User, error) {
695 var id, username, password string
696 err := s.db.QueryRow(context.Background(),
697 `SELECT id, username, password FROM users WHERE is_admin = TRUE LIMIT 1`,
698 ).Scan(&id, &username, &password)
699 if errors.Is(err, pgx.ErrNoRows) {
700 return users.User{}, users.ErrUserNotFound
701 }
702 if err != nil {
703 return users.User{}, err
704 }
705 return users.User{ID: id, Username: username, Password: password, IsAdmin: true}, nil
706}
707
708// SetIsAdmin 设置指定用户的管理员标记。
709func (s *UserStore) SetIsAdmin(userID string, isAdmin bool) error {

Callers

nothing calls this directly

Calls 1

QueryRowMethod · 0.80

Tested by

no test coverage detected