Returns 'null' if the username is ok.
338395
private static String checkUsername(String username) {
        if (username.length() < 3) {
            return "too short (minimum: 3 characters)";
        } else if (username.length() > 64) {
            return "too long (maximum: 64 characters)";
        }

        for (int i = 0; i < username.length(); i++) {
            char c = username.charAt(i);
            if (c >= 'A' && c <= 'Z') continue;
            if (c >= 'a' && c <= 'z') continue;
            if (c >= '0' && c <= '9') continue;
            if (c == '_') continue;
            return "invalid character at position " + (i+1) + ": " + jq(""+c);
        }

        return null;
    }
984919
def get_local_user(username):
    """"""
    try:
        _ = getpwnam(username)
        luser = username
    except KeyError:
        luser = getuser()
    return luser
956460
protected boolean userAlreadyExists(String username) {

        if (m_user != null) {
            return false;
        }
        CmsUser user = null;
        try {
            user = m_cms.readUser(m_ou.getValue() + username);
        } catch (CmsException e) {
            return false;
        }

        return user != null;

    }
698835
def username_or(user, attr):
    
    if not settings.ACCOUNTS_NO_USERNAME:
        attr = "username"
    value = getattr(user, attr)
    if callable(value):
        value = value()
    return value
24487
async function getUsersIdsToNotify(thing, checkValueAccess) {
	
	if (!thing)
		throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Thing can't be null", 26);
	
	let UsersIdsToNotify = new Set();
	
	for(let r of thing.usersRights) {
	
		if (!(
			((r.userStatus & (thConstants.ThingUserStates.Ok | thConstants.ThingUserStates.WaitForAuth)) != 0) &&
				((r.userVisibility & thConstants.ThingUserVisibility.Visible) != 0))
		)
			continue;

		let userId = r.userId;
		let username = r.username;
	
		if (!userId && !username)
			throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Both userId and username can't be empty", 27);
		
		let user = userId ? await usersManager.findUserById(userId) : await	usersManager.findUserByUsername(username);
		if (!user)
			continue;

		if (checkValueAccess) {
			let thingUserClaims = getThingUserClaims(user, thing, user.isSuperAdministrator);
			if ((thingUserClaims.change & thConstants.ThingUserChangeClaims.CanChangeValue) == 0)
				continue;
		}
			
		UsersIdsToNotify.add(userId);
	}
	
	return UsersIdsToNotify;
}
108134
public function getUsername()
    {
        $username = null;
        $link = $this->getLink();

        if (!empty($link)) {
            $username = substr($link, strrpos($link, '/') + 1);
        }

        return $username;
    }
329337
def username_matches_request_user(view_fn):
    
    @wraps(view_fn)
    def wrapper(request, username, *args, **kwargs):
        User = get_user_model()

        user = get_object_or_404(User, username=username)
        if user != request.user:
            return HttpResponseForbidden()
        else:
            return view_fn(request, user, *args, **kwargs)

    return wrapper
267553
private String username( String username ) {
        return (username.startsWith("<") && username.endsWith(">")) ? username.substring(1, username.length() - 1) : username;
    }
344490
def is_username(string, minlen=1, maxlen=15):
    
    if string:
        string = string.strip()
        return username_re.match(string) and (minlen <= len(string) <= maxlen)
    return False
1306890
public function getUsername() {
		if (isset($_SESSION) && isset($_SESSION[self::SESSION_FIELD_USERNAME])) {
			return $_SESSION[self::SESSION_FIELD_USERNAME];
		}
		else {
			return null;
		}
	}
540153
public function checkUsername() {
    if (!Tilmeld::$config['email_usernames']) {
      if (empty($this->username)) {
        return ['result' => false, 'message' => 'Please specify a username.'];
      }
      if (Tilmeld::$config['max_username_length'] > 0
          && strlen($this->username) > Tilmeld::$config['max_username_length']
        ) {
        return [
          'result' => false,
          'message' => 'Usernames must not exceed '.
            Tilmeld::$config['max_username_length'].' characters.'
        ];
      }
      if (array_diff(
          str_split($this->username),
          str_split(Tilmeld::$config['valid_chars'])
      )) {
        return [
          'result' => false,
          'message' => Tilmeld::$config['valid_chars_notice']
        ];
      }
      if (!preg_match(Tilmeld::$config['valid_regex'], $this->username)) {
        return [
          'result' => false,
          'message' => Tilmeld::$config['valid_regex_notice']
        ];
      }
      $selector = ['&',
        'ilike' => [
          'username',
          str_replace(
              ['\\', '%', '_'],
              ['\\\\\\\\', '\%', '\_'],
              $this->username
          )
        ]
      ];
      if (isset($this->guid)) {
        $selector['!guid'] = $this->guid;
      }
      $test = Nymph::getEntity(
          ['class' => '\Tilmeld\Entities\User', 'skip_ac' => true],
          $selector
      );
      if (isset($test->guid)) {
        return ['result' => false, 'message' => 'That username is taken.'];
      }

      return [
        'result' => true,
        'message' => (
          isset($this->guid) ? 'Username is valid.' : 'Username is available!'
        )
      ];
    } else {
      if (empty($this->username)) {
        return ['result' => false, 'message' => 'Please specify an email.'];
      }
      if (Tilmeld::$config['max_username_length'] > 0
          && strlen($this->username) > Tilmeld::$config['max_username_length']
        ) {
        return [
          'result' => false,
          'message' => 'Emails must not exceed '.
            Tilmeld::$config['max_username_length'].' characters.'
        ];
      }

      return $this->checkEmail();
    }
  }
972950
public String determineUsername() {
		if (StringUtils.hasText(this.username)) {
			return this.username;
		}
		if (EmbeddedDatabaseConnection.isEmbedded(determineDriverClassName())) {
			return "sa";
		}
		return null;
	}
46130
@Override
    public String getName() {
        final Object attributeValue = this.getAttributeValue(this.userNameAttribute);
        if (attributeValue == null) {
            return null;
        }

        return attributeValue.toString();
    }
979007
public boolean hasUserGrant(Grant grant,String username){
        if (grant == null) throw new IllegalArgumentException("grant cannot be null");
        if (username==null) throw new IllegalArgumentException("username cannot be null");
        Set<String> users = userGrants.get(grant);
        return users!=null &&users.contains(username);
    }
243545
def find_by_username(self, username):
        """"""
        data = (db.select(self.table).select('username', 'email', 'real_name',
                                             'password', 'bio', 'status', 'role', 'uid').
                condition('username', username).execute()
                )
        if data:
            return self.load(data[0], self.model)
699565
@Nullable
  public IUser getUserOfLoginName (@Nullable final String sLoginName)
  {
    if (StringHelper.hasNoText (sLoginName))
      return null;

    return findFirst (x -> x.getLoginName ().equals (sLoginName));
  }
162652
@Override
  public final String getUserName() {
    if (httpReq.getUserPrincipal() != null) {
      return httpReq.getUserPrincipal().getName();
    }
    return null;
  }