From fff0a6c562eb4ccabdbd14b4ad2e6d12df407093 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 12 Aug 2016 20:31:49 +0530 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + plinth/modules/users/views.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3676a8095..c5ca90155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/plinth/modules/users/views.py b/plinth/modules/users/views.py index 3c56d0412..253f759e6 100644 --- a/plinth/modules/users/views.py +++ b/plinth/modules/users/views.py @@ -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):