superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] yamoe edited a comment on issue #4518: Add Admin Reset Password Capability
Date Mon, 02 Jul 2018 11:38:10 GMT
yamoe edited a comment on issue #4518: Add Admin Reset Password Capability
   currently available in the menu below.
   "Security > List Users > Show record > Reset Password"
   customizing if you want to edit on page "Edit record"
           from werkzeug.datastructures import ImmutableMultiDict
           from import generate_password_hash
           from import UserDBModelView
           from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget
           from wtforms.validators import EqualTo
           from wtforms import PasswordField
           from flask_babel import lazy_gettext
           class MyUserDBModelView(UserDBModelView):
               __class__ = UserDBModelView
               edit_form_extra_fields = {'password': PasswordField(lazy_gettext('Password'),
                       'Please use a good password policy, this application does not check
this for you'),
                   'conf_password': PasswordField(lazy_gettext('Confirm Password'),
                       'Please rewrite the user\'s password to confirm'),
                       validators=[EqualTo('password', message=lazy_gettext(
                       'Passwords must match'))],
               edit_columns = ['first_name', 'last_name', 'username', 'active', 'email', 'roles',
'password', 'conf_password']
               stat = type('', (object,), { 'none': 0, 'use': 1, 'notuse': 2 })()
               def __init__(self, **kwargs):
                   super(MyUserDBModelView, self).__init__(**kwargs)
                   self.edit_form.refresh = MyUserDBModelView.wrap_refresh(self, self.edit_form.refresh)
               def wrap_refresh(self, wfunc):
                   wfunc = wfunc.__func__
                   def _w(*args, **kwargs):
                       pw = None
                       s = self.stat.none
                       obj = args[1] if len(args) >= 2 else None
                       if isinstance(obj, ImmutableMultiDict):
                           pw = obj.get('password', None)
                           cpw = obj.get('conf_password', None)
                           if pw and cpw:
                               pw = pw.strip()
                               cpw = cpw.strip()
                               if pw and cpw and pw == cpw:
                                   s = self.stat.use
                                   pw = generate_password_hash(pw)
                               s = self.stat.notuse
                       form = wfunc(*args, **kwargs)
                       if s == self.stat.use:
                       elif s == self.stat.notuse:
                       return form
                   return classmethod(_w)
           from import SupersetSecurityManager
           from .views import MyUserDBModelView
           class MySecurityManager(SupersetSecurityManager):
               userdbmodelview = MyUserDBModelView
           CUSTOM_SECURITY_MANAGER = MySecurityManager

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message