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

Method IsUsernameUsed

internal/database/users.go:791–800  ·  view source on GitHub ↗

IsUsernameUsed returns true if the given username has been used other than the excluded user (a non-positive ID effectively meaning check against all users).

(ctx context.Context, username string, excludeUserID int64)

Source from the content-addressed store, hash-verified

789// the excluded user (a non-positive ID effectively meaning check against all
790// users).
791func (s *UsersStore) IsUsernameUsed(ctx context.Context, username string, excludeUserID int64) bool {
792 if username == "" {
793 return false
794 }
795 return s.db.WithContext(ctx).
796 Select("id").
797 Where("lower_name = ? AND id != ?", strings.ToLower(username), excludeUserID).
798 First(&User{}).
799 Error != gorm.ErrRecordNotFound
800}
801
802// List returns a list of users. Results are paginated by given page and page
803// size, and sorted by primary key (id) in ascending order.

Callers 5

ChangeUsernameMethod · 0.95
CreateMethod · 0.95
CreateOrganizationFunction · 0.80
usersIsUsernameUsedFunction · 0.80
SettingsPostFunction · 0.80

Calls 1

WhereMethod · 0.80

Tested by 1

usersIsUsernameUsedFunction · 0.64