Confirm a reservation for a username.

        The default implementation just calls :py:func:`~xmpp_backends.base.XmppBackendBase.set_password` and
        optionally :py:func:`~xmpp_backends.base.XmppBackendBase.set_email`.
192357
def confirm_reservation(self, username, domain, password, email=None):
        
        self.set_password(username=username, domain=domain, password=password)
        if email is not None:
            self.set_email(username=username, domain=domain, email=email)
451693
def save(self, *args, **kwargs):
        
        created = self.pk is None
        sync_emailaddress = kwargs.pop('sync_emailaddress', True)
        # ensure usable password
        if created and self.has_usable_password() is False:
            self.set_password(self.password)
        # save
        super(Profile, self).save(*args, **kwargs)
        # add user to default group
        if created and self.groups.count() < 1:
            # TODO: make default group configurable in settings
            try:
                default_group = Group.objects.get(name='registered')
                self.groups.add(default_group)
            except Group.DoesNotExist:
                pass
        # keep in sync with EmailAddress model
        if (EMAIL_CONFIRMATION and sync_emailaddress
                               and self.email  # noqa
                               and self.email_set.filter(email=self.email).count() < 1):  # noqa
            self.email_set.add_email(self, email=self.email)
            self.email_set.last().set_as_primary()
1106970
function auth (username, password, callback) {
    return relax({
      method: 'POST',
      db: '_session',
      form: {
        name: username,
        password: password
      }
    }, callback)
  }
1021177
def check_password(self, raw_password):
        """"""
        return xmpp_backend.check_password(self.node, self.domain, raw_password)
869380
def auth(self, user=None, password=None, jsonp=None):
        
        if not user:
            user = self.user
        if not password:
            password = self.password
        parameters = {
                      'username' : self.user,
                      'password' : self.password
                     }
        if jsonp is not None:
            parameters['jsonp'] = jsonp
        status, headers = self._query(self.authurl, parameters)
        # return the callback call if we want jsonp
        if jsonp is not None:
            return status
        return (int(status), self.auth_status_codes[int(status)])
1191404
def change_email(self, old_email, new_email):
        
        log.info("[+] Changing account email to '{}'".format(new_email))
        return self._send_xmpp_element(account.ChangeEmailRequest(self.password, old_email, new_email))
973117
def cli(ctx, email, first_name, last_name, password, metadata={}):
    
    return ctx.gi.users.update_user(email, first_name, last_name, password, metadata=metadata)
933982
def register(email):
    '''
    
    '''
    data = __utils__['http.query'](
        '{0}/useraccounts'.format(_base_url()),
        method='POST',
        data=salt.utils.json.dumps({
            'username': email,
            'userAccountType': 'API',
        }),
        status=True,
        decode=True,
        decode_type='json',
        header_dict={
            'Content-Type': 'application/json',
        },
    )
    status = data['status']
    if six.text_type(status).startswith('4') or six.text_type(status).startswith('5'):
        raise CommandExecutionError(
            'There was an API error: {0}'.format(data['error'])
        )
    return data.get('dict', {})
568997
def authenticate(self, username="", password="", **kwargs):
        """"""
        try:
            user = get_user_model().objects.filter(email__iexact=username)[0]
            if check_password(password, user.password):
                return user
            else:
                return None
        except IndexError:
            # No user was found, return None - triggers default login failed
            return None
1110675
def set_user_password(name, passwd, **client_args):
    '''
    
    '''
    if not user_exists(name, **client_args):
        log.info('User \'%s\' does not exist', name)
        return False

    client = _client(**client_args)
    client.set_user_password(name, passwd)

    return True
494227
def SetCredentials(self, password=None, username=None):
    
    if password:
      self._password = password
    if username:
      self._user = username
1329858
def SetUsername(self, username):
    
    self._username = username
    logger.debug('Elasticsearch username: {0!s}'.format(username))
691548
def gen_reset_password_token(self, user=None, send_email=None):
        
        if not user and "form" in current_context.data and request.method == "POST":
            form = current_context.data.form
            user = self.find_by_email(form[self.options["email_column"]].data)
            if user is None:
                if self.options["reset_password_token_error_message"]:
                    flash(self.options["reset_password_token_error_message"], "error")
                current_context.exit(trigger_action_group="reset_password_failed")
                
        if not user:
            raise InvalidOptionError("Invalid user in 'reset_password_token' action")

        token = self._gen_reset_password_token(user)
        self.reset_password_token_signal.send(self, user=user, token=token)
        if (send_email is None and self.options["send_reset_password_email"]) or send_email:
            to_email = getattr(user, self.options["email_column"])
            current_app.features.emails.send(to_email, "users/reset_password.txt", user=user, token=token)
        return token
604963
def _check_settings(self, app):
        """"""

        # Check for invalid settings
        # --------------------------

        # Check self.UserInvitationClass and USER_ENABLE_INVITE_USER
        if self.USER_ENABLE_INVITE_USER and not self.UserInvitationClass:
            raise ConfigError(
                'UserInvitationClass is missing while USER_ENABLE_INVITE_USER is True.' \
                ' Specify UserInvitationClass with UserManager(app, db, User, UserInvitationClass=...' \
                ' or set USER_ENABLE_INVITE_USER=False.')

        # Check for deprecated settings
        # -----------------------------

        # Check for deprecated USER_ENABLE_CONFIRM_EMAIL
        setting = app.config.get('USER_ENABLE_LOGIN_WITHOUT_CONFIRM_EMAIL', None)
        if setting is not None:
            print(
                'Deprecation warning: USER_ENABLE_LOGIN_WITHOUT_CONFIRM_EMAIL'\
                ' will be deprecated.' \
                ' It has been replaced by USER_ALLOW_LOGIN_WITHOUT_CONFIRMED_EMAIL.'\
                ' Please change this as soon as possible.')
            self.USER_ALLOW_LOGIN_WITHOUT_CONFIRMED_EMAIL = setting

        # Check for deprecated USER_ENABLE_RETYPE_PASSWORD
        setting = app.config.get('USER_ENABLE_RETYPE_PASSWORD', None)
        if setting is not None:
            print(
                'Deprecation warning: USER_ENABLE_RETYPE_PASSWORD'\
                ' will be deprecated.' \
                ' It has been replaced with USER_REQUIRE_RETYPE_PASSWORD.'\
                ' Please change this as soon as possible.')
            self.USER_REQUIRE_RETYPE_PASSWORD = setting

        # Check for deprecated USER_SHOW_USERNAME_EMAIL_DOES_NOT_EXIST
        setting = app.config.get('USER_SHOW_USERNAME_EMAIL_DOES_NOT_EXIST', None)
        if setting is not None:
            print(
                'Deprecation warning: USER_SHOW_USERNAME_EMAIL_DOES_NOT_EXIST' \
                ' will be deprecated.' \
                ' It has been replaced with USER_SHOW_USERNAME_DOES_NOT_EXIST'
                ' and USER_SHOW_EMAIL_DOES_NOT_EXIST.'
                ' Please change this as soon as possible.')
            self.USER_SHOW_USERNAME_DOES_NOT_EXIST = setting
            self.USER_SHOW_EMAIL_DOES_NOT_EXIST = setting

        # Check for deprecated USER_PASSWORD_HASH
        setting = app.config.get('USER_PASSWORD_HASH', None)
        if setting is not None:
            print(
                "Deprecation warning: USER_PASSWORD_HASH=<string>"\
                " will be deprecated."\
                " It has been replaced with USER_PASSLIB_CRYPTCONTEXT_SCHEMES=<list>."
                " Please change USER_PASSWORD_HASH='something' to"\
                " USER_PASSLIB_CRYPTCONTEXT_SCHEMES=['something'] as soon as possible.")
            self.USER_PASSLIB_CRYPTCONTEXT_SCHEMES = [setting]

        # Check that USER_EMAIL_SENDER_EMAIL is set when USER_ENABLE_EMAIL is True
        if not self.USER_EMAIL_SENDER_EMAIL and self.USER_ENABLE_EMAIL:
            raise ConfigError(
                'USER_EMAIL_SENDER_EMAIL is missing while USER_ENABLE_EMAIL is True.'\
                ' specify USER_EMAIL_SENDER_EMAIL (and USER_EMAIL_SENDER_NAME) or set USER_ENABLE_EMAIL to False.')

        # Disable settings that rely on a feature setting that's not enabled
        # ------------------------------------------------------------------

        # USER_ENABLE_REGISTER=True must have USER_ENABLE_USERNAME=True or USER_ENABLE_EMAIL=True.
        if not self.USER_ENABLE_USERNAME and not self.USER_ENABLE_EMAIL:
            self.USER_ENABLE_REGISTER = False

        # Settings that depend on USER_ENABLE_EMAIL
        if not self.USER_ENABLE_EMAIL:
            self.USER_ENABLE_CONFIRM_EMAIL = False
            self.USER_ENABLE_MULTIPLE_EMAILS = False
            self.USER_ENABLE_FORGOT_PASSWORD = False
            self.USER_SEND_PASSWORD_CHANGED_EMAIL = False
            self.USER_SEND_REGISTERED_EMAIL = False
            self.USER_SEND_USERNAME_CHANGED_EMAIL = False
            self.USER_REQUIRE_INVITATION = False

        # Settings that depend on USER_ENABLE_USERNAME
        if not self.USER_ENABLE_USERNAME:
            self.USER_ENABLE_CHANGE_USERNAME = False
548077
def update_user(self, user, email=None, username=None,
            uid=None, defaultRegion=None, enabled=None):
        
        user_id = utils.get_id(user)
        uri = "users/%s" % user_id
        upd = {"id": user_id}
        if email is not None:
            upd["email"] = email
        if defaultRegion is not None:
            upd["RAX-AUTH:defaultRegion"] = defaultRegion
        if username is not None:
            upd["username"] = username
        if enabled is not None:
            upd["enabled"] = enabled
        data = {"user": upd}
        resp, resp_body = self.method_put(uri, data=data)
        if resp.status_code in (401, 403, 404):
            raise exc.AuthorizationFailure("You are not authorized to update "
                    "users.")
        return User(self, resp_body)
1207178
def set_basic_auth(self, username, password):
        
        from requests.auth import HTTPBasicAuth
        self.auth = HTTPBasicAuth(username, password)
        return self
35426
def auth(username, password):
    '''
    
    '''
    django_auth_path = __opts__['django_auth_path']
    if django_auth_path not in sys.path:
        sys.path.append(django_auth_path)
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', __opts__['django_auth_settings'])

    __django_auth_setup()

    if not is_connection_usable():
        connection.close()

    import django.contrib.auth  # pylint: disable=import-error,3rd-party-module-not-gated
    user = django.contrib.auth.authenticate(username=username, password=password)
    if user is not None:
        if user.is_active:
            log.debug('Django authentication successful')
            return True
        else:
            log.debug('Django authentication: the password is valid but the account is disabled.')
    else:
        log.debug('Django authentication failed.')

    return False