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 authored and James Valleroy committed 2016-08-12 16:10:32 -04:00
1 parent 3a864cd203
commit fff0a6c562
2 files changed
+8 -2

No files matched your search

+7 -2
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):