mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
Show if user is also a POSIX user in edit user form.
This commit is contained in:
parent
45b5ce8de9
commit
2da8619248
28
actions/check-user-exists
Executable file
28
actions/check-user-exists
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This file is part of Plinth.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Can be run as normal user.
|
||||
|
||||
username="$1"
|
||||
|
||||
getent passwd "$username" >/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "User exists"
|
||||
else
|
||||
echo "User does not exist"
|
||||
fi
|
||||
@ -46,6 +46,11 @@
|
||||
|
||||
{{ form|bootstrap }}
|
||||
|
||||
{% if is_posix_user %}
|
||||
<p>This user is also a POSIX user and (if active) can log in to the
|
||||
system through SSH.</p>
|
||||
{% endif %}
|
||||
|
||||
<input type="submit" class="btn btn-primary" value="Save Changes"/>
|
||||
|
||||
</form>
|
||||
|
||||
@ -26,6 +26,7 @@ from django.views.generic import ListView
|
||||
from gettext import gettext as _
|
||||
|
||||
from .forms import CreateUserForm, UserUpdateForm, UserChangePasswordForm
|
||||
from plinth import actions
|
||||
|
||||
|
||||
subsubmenu = [{'url': reverse_lazy('users:index'),
|
||||
@ -70,6 +71,12 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView):
|
||||
success_message = _('User %(username)s updated.')
|
||||
title = _('Edit User')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UserUpdate, self).get_context_data(**kwargs)
|
||||
output = actions.run('check-user-exists', [self.object.username])
|
||||
context['is_posix_user'] = 'User exists' in output
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
"""Return the URL to redirect to in case of successful updation."""
|
||||
return reverse('users:edit', kwargs={'slug': self.object.username})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user