예제 #1
0
    def delete_user(self, user):
        """
        Deletes the user account.

        Returns True if the account existed and was deleted, False otherwise.
        """

        if self.sql_read_only:
            return False

        if not self.check_prereqs():
            return False

        if not self.has_user(user):
            return False

        db = self.env.get_db_cnx()
        cursor = db.cursor()

        query = self.create_query(self.sql_delete_user_query, {
            'username_field': self.sql_username_field,
            'username': user
        })
        self.log.debug("sqlflexibleauthstore: delete_user: %s" % (query, ))
        cursor.execute(query)

        db.commit()
        del_user_attribute(self.env, username=user)
        return True
예제 #2
0
    def delete_user(self, user):
        """
        Deletes the user account.

        Returns True if the account existed and was deleted, False otherwise.
        """

        if self.sql_read_only:
            return False

        if not self.check_prereqs():
            return False

        if not self.has_user(user):
            return False

        db = self.env.get_db_cnx()
        cursor = db.cursor()

        query=self.create_query(self.sql_delete_user_query,{'username_field':self.sql_username_field,'username':user})
        self.log.debug("sqlflexibleauthstore: delete_user: %s" % (query,))
        cursor.execute(query)

        db.commit()
        del_user_attribute(self.env,username=user)
        return True
예제 #3
0
 def _do_config(self, req):
     stores = StoreOrder(stores=self.acctmgr.stores,
                         list=self.acctmgr.password_store)
     if req.method == 'POST':
         if req.args.get('restart'):
             del_user_attribute(self.env, attribute='password_refreshed')
             req.redirect(req.href.admin('accounts', 'config',
                                         done='restart'))
         _setorder(req, stores)
         self.config.set('account-manager', 'password_store',
                         ','.join(stores.get_enabled_store_names()))
         for store in stores.get_all_stores():
             for attr, option in _getoptions(store):
                 cls_name = store.__class__.__name__
                 newvalue = req.args.get('%s.%s' % (cls_name, attr))
                 self.log.debug("%s.%s: %s" % (cls_name, attr, newvalue))
                 if newvalue is not None:
                     self.config.set(option.section, option.name, newvalue)
                     self.config.save()
         self.config.set('account-manager', 'force_passwd_change',
                         req.args.get('force_passwd_change', False))
         self.config.set('account-manager', 'persistent_sessions',
                         req.args.get('persistent_sessions', False))
         self.config.set('account-manager', 'verify_email',
                         req.args.get('verify_email', False))
         self.config.set('account-manager', 'refresh_passwd',
                         req.args.get('refresh_passwd', False))
         self.config.save()
     sections = []
     for store in self.acctmgr.stores:
         if store.__class__.__name__ == "ResetPwStore":
             # Exclude special store, that is used strictly internally and
             # inherits configuration from SessionStore anyway.
             continue
         options = []
         for attr, option in _getoptions(store):
             opt_val = option.__get__(store, store)
             opt_val = isinstance(opt_val, Component) and \
                       opt_val.__class__.__name__ or opt_val
             options.append(
                         {'label': attr,
                         'name': '%s.%s' % (store.__class__.__name__, attr),
                         'value': opt_val,
                         'doc': gettext(option.__doc__)
                         })
             continue
         sections.append(
                     {'name': store.__class__.__name__,
                     'classname': store.__class__.__name__,
                     'order': stores[store],
                     'options' : options,
                     })
         continue
     sections = sorted(sections, key=lambda i: i['name'])
     numstores = range(0, stores.numstores() + 1)
     data = {
         '_': _,
         'sections': sections,
         'numstores': numstores,
         'force_passwd_change': self.acctmgr.force_passwd_change,
         'persistent_sessions': self.acctmgr.persistent_sessions,
         'verify_email': self.acctmgr.verify_email,
         'refresh_passwd': self.acctmgr.refresh_passwd,
         }
     result = req.args.get('done')
     if result == 'restart':
         data['result'] = _("Password hash refresh procedure restarted.")
     return 'admin_accountsconfig.html', data