Given the verified username, look up and return the
        corresponding user account if it exists, or ``None`` if it
        doesn't.
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
727700
def user_exists(username, domain='', database=None, **kwargs):
    '''
    
    '''
    if domain:
        username = '{0}\\{1}'.format(domain, username)
    if database:
        kwargs['database'] = database
    # We should get one, and only one row
    return len(tsql_query(query="SELECT name FROM sysusers WHERE name='{0}'".format(username), **kwargs)) == 1
872081
def verify(cls, user_id, verification_hash):
        
        user = yield cls.get(user_id)

        # If user does not have verification hash then this means they have already been verified
        if 'verification_hash' not in user._resource:
            raise Return(user)

        if user.verification_hash != verification_hash:
            raise exceptions.ValidationError('Invalid verification hash')

        del user.verification_hash
        yield user._save()

        raise Return(user)
820225
def get_authenticated_user(self, callback):
        
        # Verify the OpenID response via direct request to the OP
        args = dict((k, v) for k, v in request.args.items())
        args["openid.mode"] = u"check_authentication"

        r = requests.post(self._OPENID_ENDPOINT, data=args)
        return self._on_authentication_verified(callback, r)
984908
def check_username_for_new_account(person, username):
    

    query = Account.objects.filter(
        username__exact=username,
        date_deleted__isnull=True)

    if query.count() > 0:
        raise UsernameTaken(
            six.u('Username already in use.')
        )

    if account_exists(username):
        raise UsernameTaken(
            six.u('Username is already in datastore.')
        )

    return username
1075490
def is_username_available(self, username):
        """"""
        params = {'user': username}
        try:
            result = self.request_json(self.config['username_available'],
                                       params=params)
        except errors.BadUsername:
            return False
        return result
359155
def find_user(self, username=None, email=None):
        
        if username:
            return (
                self.get_session.query(self.user_model)
                .filter(func.lower(self.user_model.username) == func.lower(username))
                .first()
            )
        elif email:
            return (
                self.get_session.query(self.user_model).filter_by(email=email).first()
            )
377376
def username_is_available(self, new_username):
        

        # Return True if new_username equals current user's username
        if self.user_manager.call_or_get(current_user.is_authenticated):
            if new_username == current_user.username:
                return True

        # Return True if new_username does not exist,
        # Return False otherwise.
        return self.find_user_by_username(new_username) == None
464102
def _get_username_from_userinfo(self, user_info):
        

        subject = user_info['sub']
        email = user_info['email']

        if "Mozilla-LDAP" in subject:
            return "mozilla-ldap/" + email
        elif "email" in subject:
            return "email/" + email
        elif "github" in subject:
            return "github/" + email
        elif "google" in subject:
            return "google/" + email
        # Firefox account
        elif "oauth2" in subject:
            return "oauth2/" + email
        else:
            raise AuthenticationFailed("Unrecognized identity")
1269796
def request_verification(self, user, identity):
        
        return UserIdentityRequest(self).put(self.endpoint.request_verification, user, identity)
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
818746
def _verify_credentials(self):
        
        r = requests.get(self.apiurl + "account/verify_credentials.xml",
                         auth=HTTPBasicAuth(self._username, self._password),
                         headers=self.header)
        if r.status_code != 200:
            raise UserLoginFailed("Username or Password incorrect.")
430803
def get_claimed_username(token):
    
    unverified_data = jwt.decode(token, options={
        'verify_signature': False
    })

    if 'username' not in unverified_data:
        return None
    return unverified_data['username']
244979
def get_user(self, validated_token):
        
        try:
            user_id = validated_token[api_settings.USER_ID_CLAIM]
        except KeyError:
            raise InvalidToken(_('Token contained no recognizable user identification'))

        try:
            user = User.objects.get(**{api_settings.USER_ID_FIELD: user_id})
        except User.DoesNotExist:
            raise AuthenticationFailed(_('User not found'), code='user_not_found')

        if not user.is_active:
            raise AuthenticationFailed(_('User is inactive'), code='user_inactive')

        return user
171163
def check_auth(username, password):
    
    return (username == settings.PRIVATE_INDEX_USERNAME and
            settings.PRIVATE_INDEX_PASSWORD and
            password == settings.PRIVATE_INDEX_PASSWORD)
490743
def valid_username(user):
    '''
    
    '''
    if not isinstance(user, six.string_types):
        return False

    if len(user) > 32:
        return False

    return VALID_USERNAME.match(user) is not None
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)