GET /auth/usernameAvailable - checks if a username is available. depends on users, or providerAccounts
173298
function getAuthUsernameAvailable(req, res) {

    if (!req.query || !req.query.username) {
      res.status(400).send('Please provide a username');
    } else {
      var query = {
        username: req.query.username
      };

      var userCollection = authConfig.strategy === 'password' ? users :
        providerAccounts;

      userCollection.find(query).exec()
        .then(function (matchingUsers) {
          res.status(200).send({
            data: matchingUsers.length === 0
          });
        })
        .then(null, util.makeErrorResponder(res));
    }
  }
434576
def show(self, username):
        """"""
        filter = ['(objectclass=posixAccount)', "(uid={})".format(username)]
        return self.client.search(filter)
1243035
def _resolve_username(self, account, username):
        """"""
        if account is not None:
            warnings.warn(
                "Use keyword argument 'username' instead of 'account'",
                DeprecationWarning)
        return username or account or self.username
967412
def _is_admin(self, username):
        
        roles = self._get_roles(username)
        return self.roles.is_admin(roles['roles'])
264429
function getUser(username, done) {
  return getModels(function(m) {
    return m.collections.user.findOne({ username })
      .populate("tokens")
      .populate("groups")
      .populate("leading")
      .exec(done);
  });
}
1048207
def get_user(self, username="", ext_collections=False, ext_galleries=False):

        

        if not username and self.standard_grant_type == "authorization_code":
            response = self._req('/user/whoami')
            u = User()
            u.from_dict(response)
        else:
            if not username:
                raise DeviantartError("No username defined.")
            else:
                response = self._req('/user/profile/{}'.format(username), {
                    'ext_collections' : ext_collections,
                    'ext_galleries' : ext_galleries
                })
                u = User()
                u.from_dict(response['user'])

        return u
864728
def get_users(username):
    
    reply = {}

    log.debug('Begin /v[x]/users/' + username)

    if username is None:
        reply['error'] = "No username given"
        return jsonify(reply), 404

    if ',' in username:
        reply['error'] = 'Multiple username queries are no longer supported.'
        return jsonify(reply), 401


    if "." not in username:
        fqa = "{}.{}".format(username, 'id')
    else:
        fqa = username

    profile = get_profile(fqa)

    reply[username] = profile
    if 'error' in profile:
        status_code = 200
        if 'status_code' in profile:
            status_code = profile['status_code']
            del profile['status_code']
        return jsonify(reply), status_code
    else:
        return jsonify(reply), 200
1046473
def get_user_if_exists(strategy, details, user=None, *args, **kwargs):
    """"""
    if user:
        return {'is_new': False}
    try:
        username = details.get('username')

        # Return the user if it exists
        return {
            'is_new': False,
            'user': User.objects.get(username=username)
        }
    except User.DoesNotExist:
        # Fall to the default return value
        pass

    # Nothing to return since we don't have a user
    return {}
71276
def API_GET(self):  # pylint: disable=arguments-differ
        
        if self.user_manager.session_logged_in():
            return 200, {"authenticated": True, "username": self.user_manager.session_username()}
        else:
            return 200, {"authenticated": False}
1107950
def check_user(self, username, email):
        ''''''
        users = self.router.user
        avail = yield users.filter(username=username).count()
        if avail:
            raise FieldError('Username %s not available' % username)
        if email:
            avail = yield users.filter(email=email).count()
            if avail:
                raise FieldError('Email %s not available' % email)
693866
def get_member_details(self, username):
        
        members = self.get_members()
        for member in members:
            if member.username == username:
                return member
167533
def get_user(self, username):
        
        User = get_user_model()  # noqa
        try:
            user = User.objects.get(**{
                User.USERNAME_FIELD: username,
                'is_active': False
            })
            return user
        except User.DoesNotExist:
            return None
889581
def find_user(session, username):
    """"""
    resp = _make_request(session, FIND_USER_URL, username)
    if not resp:
        raise VooblyError('user not found')
    try:
        return int(resp[0]['uid'])
    except ValueError:
        raise VooblyError('user not found')
96914
def _is_auth_info_available():
  """"""
  return (_ENDPOINTS_USER_INFO in os.environ or
          (_ENV_AUTH_EMAIL in os.environ and _ENV_AUTH_DOMAIN in os.environ) or
          _ENV_USE_OAUTH_SCOPE in os.environ)
1337889
def _getUsername(self):
        
        for (l, d) in getAccountNames(self.store):
            return l + u'@' + d
625675
def get_user_by_username(self, username):
        
        results = self.get_users(filter='username eq "%s"' % (username))
        if results['totalResults'] == 0:
            logging.warning("Found no matches for given username.")
            return
        elif results['totalResults'] > 1:
            logging.warning("Found %s matches for username %s" %
                (results['totalResults'], username))

        return results['resources'][0]
873289
def db_user_exists(username):
    
    qry = u"""SELECT COUNT(*) FROM pg_roles where rolname = \'{username}\';"""
    output = StringIO()
    excute_query(
        qry.format(username=username),
        flags="-Aqt",
        use_sudo=True,
        stdout=output
    )
    # FIXME: is there a way to get fabric to not clutter the output
    # with "[127.0.0.1] out:" on each line?
    lines = output.getvalue().splitlines()
    return lines and lines[0].endswith('out: 1')