users: Add list of restricted usernammes

List is derived from optional services installed.
This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2016-08-12 18:48:16 +05:30
1 parent 3a69958165
commit c8c6bc377b
2 files changed
+24 -4

No files matched your search

+3 -2
View File
@@ -35,7 +35,7 @@ from plinth import cfg
from plinth.errors import ActionError, DomainRegistrationError
from plinth.modules.pagekite.utils import PREDEFINED_SERVICES, run
from plinth.modules.security import set_restricted_access
from plinth.modules.users.forms import GROUP_CHOICES
from plinth.modules.users.forms import GROUP_CHOICES, RESTRICTED_USERNAMES
from plinth.utils import format_lazy
logger = logging.getLogger(__name__)
@@ -55,7 +55,8 @@ class State1Form(auth.forms.UserCreationForm):
# Exit code 0 means that the username is already in use.
raise ValidationError(_('Username is reserved'))
except subprocess.CalledProcessError:
pass
if username in RESTRICTED_USERNAMES:
raise ValidationError(_('Username is reserved'))
return super().clean()