MCPcopy Create free account
hub / github.com/gogs/gogs / GetByUsername

Method GetByUsername

internal/database/users.go:746–756  ·  view source on GitHub ↗

GetByUsername returns the user with given username. It returns ErrUserNotExist when not found.

(ctx context.Context, username string)

Source from the content-addressed store, hash-verified

744// GetByUsername returns the user with given username. It returns
745// ErrUserNotExist when not found.
746func (s *UsersStore) GetByUsername(ctx context.Context, username string) (*User, error) {
747 user := new(User)
748 err := s.db.WithContext(ctx).Where("lower_name = ?", strings.ToLower(username)).First(user).Error
749 if err != nil {
750 if errors.Is(err, gorm.ErrRecordNotFound) {
751 return nil, ErrUserNotExist{args: errutil.Args{"name": username}}
752 }
753 return nil, err
754 }
755 return user, nil
756}
757
758// GetByKeyID returns the owner of given public key ID. It returns
759// ErrUserNotExist when not found.

Callers 15

PushUpdateFunction · 0.80
CommitRepoMethod · 0.80
PushTagMethod · 0.80
TransferOwnershipFunction · 0.80
GetRepositoryByRefFunction · 0.80
usersAuthenticateFunction · 0.80
usersCreateFunction · 0.80
usersGetByUsernameFunction · 0.80
HandleOrgAssignmentFunction · 0.80
GetUserByUsernameMethod · 0.80
RepoAssignmentFunction · 0.80
ServeGoGetFunction · 0.80

Calls 1

WhereMethod · 0.80

Tested by 3

usersAuthenticateFunction · 0.64
usersCreateFunction · 0.64
usersGetByUsernameFunction · 0.64