Fix handling of (missing) password when user is edited

was accidentally blanking them out, if no password was provided...
This commit is contained in:
Lance Edgar 2018-05-30 16:31:19 -05:00
parent 9ece43ce57
commit 75b48fdaae

View file

@ -67,7 +67,7 @@ class UsersView(PrincipalMasterView):
'display_name',
'active',
'active_sticky',
'password',
'set_password',
'roles',
]
@ -98,7 +98,6 @@ class UsersView(PrincipalMasterView):
def configure_grid(self, g):
super(UsersView, self).configure_grid(g)
del g.filters['password']
del g.filters['salt']
g.filters['username'].default_active = True
g.filters['username'].default_verb = 'contains'
@ -106,7 +105,9 @@ class UsersView(PrincipalMasterView):
g.filters['active'].default_verb = 'is_true'
g.filters['person'] = g.make_filter('person', model.Person.display_name,
default_active=True, default_verb='contains')
g.filters['password'] = g.make_filter('password', model.User.password,
# password
g.set_filter('password', model.User.password,
verbs=['is_null', 'is_not_null'])
g.set_sorter('person', model.Person.display_name)
@ -158,9 +159,8 @@ class UsersView(PrincipalMasterView):
field_display=person_display, service_url=people_url))
f.set_label('person_uuid', "Person")
# password
f.set_widget('password', dfwidget.CheckedPasswordWidget())
f.set_label('password', "Set Password")
# set_password
f.set_widget('set_password', dfwidget.CheckedPasswordWidget())
# if self.creating:
# f.set_required('password')
@ -195,7 +195,7 @@ class UsersView(PrincipalMasterView):
include_authenticated=True))
if self.viewing or self.deleting:
f.remove('password')
f.remove('set_password')
def get_possible_roles(self):
excluded = [
@ -208,8 +208,8 @@ class UsersView(PrincipalMasterView):
def objectify(self, form, data):
user = super(UsersView, self).objectify(form, data)
if data['password']:
set_user_password(user, data['password'])
if data['set_password']:
set_user_password(user, data['set_password'])
self.update_roles(user, data)
return user