1
0
mirror of https://github.com/Yubico/yubiadmin.git synced 2025-02-21 08:54:16 +01:00

Fix displaying users to delete.

This commit is contained in:
Dain Nilsson 2013-05-30 15:42:49 +02:00
parent bf8d639e10
commit e7f61a98ab
3 changed files with 18 additions and 9 deletions

View File

@ -71,6 +71,7 @@ auth_config = FileConfig(
('hsm_device', python_handler('YHSM_DEVICE', 'yhsm://localhost:5348')),
('db_config', python_handler('DATABASE_CONFIGURATION',
'sqlite:///:memory:')),
('user_registration', python_handler('ENABLE_USER_REGISTRATION', True))
]
)
@ -99,7 +100,14 @@ class SecurityForm(ConfigForm):
'Allow Empty Passwords',
description="""
Allow users with no password to log in without providing a password.
When set to False, a user with no password will be unable to log in.
When not checked, a user with no password will be unable to log in.
"""
)
user_registration = BooleanField(
'Enable User Registration',
description="""
Allow users to register themselves using the YubiAuth client interface.
When checked, accounts can be created <a href="/yubiauth/ui/">Here</a>.
"""
)
security_level = SelectField(
@ -326,9 +334,10 @@ class YubiAuthUsers(CollectionApp):
'YubiKeys': ', '.join(user.yubikeys.keys())
}, users)
def _select(self, ids):
return self.auth.session.query(self.User.name, self.User.id) \
def _labels(self, ids):
users = self.auth.session.query(self.User.name) \
.filter(self.User.id.in_(map(int, ids))).all()
return map(lambda x: x[0], users)
def _delete(self, ids):
self.auth.session.query(self.User) \

View File

@ -1,8 +1,8 @@
<legend>Confirm deletion</legend>
<p>Are you sure you wish to delete the following {{ item_name | lower }}?</p>
<ul>
{% for item in items %}
<li>{{ item.label }}</li>
{% for label in labels %}
<li>{{ label }}</li>
{% endfor %}
</ul>

View File

@ -136,8 +136,8 @@ class CollectionApp(App):
def _get(self, offset=0, limit=None):
return [{}]
def _select(self, ids):
return [x for x in self._get() if x['id'] in ids]
def _labels(self, ids):
return [x['label'] for x in self._get() if x['id'] in ids]
def _delete(self, ids):
raise Exception('Not implemented!')
@ -181,8 +181,8 @@ class CollectionApp(App):
def delete(self, request):
ids = [x[5:] for x in request.params if request.params[x] == 'on']
items = self._select(ids)
return render('table_delete', ids=','.join(ids), items=items,
labels = self._labels(ids)
return render('table_delete', ids=','.join(ids), labels=labels,
item_name=self.item_name, base_url=self.base_url)
def delete_confirm(self, request):