MCPcopy Index your code
hub / github.com/coder/coder / GetAuthorizedUsers

Method GetAuthorizedUsers

coderd/database/modelqueries.go:398–470  ·  view source on GitHub ↗
(ctx context.Context, arg GetUsersParams, prepared rbac.PreparedAuthorized)

Source from the content-addressed store, hash-verified

396}
397
398func (q *sqlQuerier) GetAuthorizedUsers(ctx context.Context, arg GetUsersParams, prepared rbac.PreparedAuthorized) ([]GetUsersRow, error) {
399 authorizedFilter, err := prepared.CompileToSQL(ctx, regosql.ConvertConfig{
400 VariableConverter: regosql.UserConverter(),
401 })
402 if err != nil {
403 return nil, xerrors.Errorf("compile authorized filter: %w", err)
404 }
405
406 filtered, err := insertAuthorizedFilter(getUsers, fmt.Sprintf(" AND %s", authorizedFilter))
407 if err != nil {
408 return nil, xerrors.Errorf("insert authorized filter: %w", err)
409 }
410
411 query := fmt.Sprintf("-- name: GetAuthorizedUsers :many\n%s", filtered)
412 rows, err := q.db.QueryContext(ctx, query,
413 arg.AfterID,
414 arg.Search,
415 arg.Name,
416 pq.Array(arg.Status),
417 pq.Array(arg.RbacRole),
418 arg.LastSeenBefore,
419 arg.LastSeenAfter,
420 arg.CreatedBefore,
421 arg.CreatedAfter,
422 arg.IncludeSystem,
423 arg.GithubComUserID,
424 pq.Array(arg.LoginType),
425 arg.IsServiceAccount,
426 arg.OffsetOpt,
427 arg.LimitOpt,
428 )
429 if err != nil {
430 return nil, err
431 }
432 defer rows.Close()
433 var items []GetUsersRow
434 for rows.Next() {
435 var i GetUsersRow
436 if err := rows.Scan(
437 &i.ID,
438 &i.Email,
439 &i.Username,
440 &i.HashedPassword,
441 &i.CreatedAt,
442 &i.UpdatedAt,
443 &i.Status,
444 &i.RBACRoles,
445 &i.LoginType,
446 &i.AvatarURL,
447 &i.Deleted,
448 &i.LastSeenAt,
449 &i.QuietHoursSchedule,
450 &i.Name,
451 &i.GithubComUserID,
452 &i.HashedOneTimePasscode,
453 &i.OneTimePasscodeExpiresAt,
454 &i.IsSystem,
455 &i.IsServiceAccount,

Callers

nothing calls this directly

Calls 9

UserConverterFunction · 0.92
insertAuthorizedFilterFunction · 0.85
QueryContextMethod · 0.80
ErrMethod · 0.80
CompileToSQLMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
ErrorfMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected