users: Fix editing users without SSH keys

When SSH keys are not available for a user, the current user edit form
errors out.  Fix this by ignoring ssh key load errors.
This commit is contained in:
Sunil Mohan Adapa 2016-08-12 20:31:49 +05:30 committed by James Valleroy
parent 3a864cd203
commit fff0a6c562
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 8 additions and 2 deletions

View File

@ -33,6 +33,7 @@ All notable changes to this project will be documented in this file.
- networks: Fixed incorrect access for retrieving DNS entries.
- Fixed issue with lost menus in Django 1.10.
- Added workaround for script prefix problem in stronghold.
- users: Fixed editing users without SSH keys.
### Changed
- Added suggested packages for ikiwiki. Removed recommends since they

View File

@ -88,8 +88,13 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView):
def get_initial(self):
"""Return the data for initial form load."""
initial = super(UserUpdate, self).get_initial()
initial['ssh_keys'] = actions.superuser_run(
'ssh', ['get-keys', '--username', self.object.username]).strip()
try:
ssh_keys = actions.superuser_run(
'ssh', ['get-keys', '--username', self.object.username])
initial['ssh_keys'] = ssh_keys.strip()
except ActionError:
pass
return initial
def get_success_url(self):