users: Handle errors better during POSIX user operations

- If during an action, user does not exist ignore.

- If during an action, return a non-zero exist status.

- Catch an errors during actions as exceptions.

- Display a message that corresponding POSIX operation failed.
This commit is contained in:
Sunil Mohan Adapa committed 2015-01-25 01:45:51 +05:30
1 parent d27cd02193
commit a3de3ae277
9 files changed
+114 -35

No files matched your search

+8 -3
View File
@@ -21,6 +21,7 @@ from django.core import validators
from gettext import gettext as _
from plinth import actions
from plinth.errors import ActionError
from plinth.modules.config import config
@@ -62,9 +63,13 @@ than 63 characters in length.'),
user.set_password(self.cleaned_data['password'])
if commit:
user.save()
actions.superuser_run(
'create-user',
[user.username, self.cleaned_data['password']])
try:
actions.superuser_run(
'create-user',
[user.get_username(), self.cleaned_data['password']])
except ActionError:
messages.error(self.request,
_('Creating POSIX system user failed.'))
self.login_user()
return user