UX improved about mail and domains

This commit is contained in:
ekhae 2019-08-16 17:59:22 +00:00 committed by Alexandre Aubin
parent 9fe7c43aef
commit 78a2d012bb
3 changed files with 31 additions and 23 deletions

View file

@ -97,15 +97,6 @@ user:
pattern: &pattern_lastname
- !!str ^([^\W\d_]{2,30}[ ,.'-]{0,3})+$
- "pattern_lastname"
-m:
full: --mail
help: Main unique email address
extra:
ask: ask_email
required: True
pattern: &pattern_email
- !!str ^[\w.-]+@([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+([^\W\d_]{2,})$
- "pattern_email"
-p:
full: --password
help: User password
@ -116,6 +107,13 @@ user:
- !!str ^.{3,}$
- "pattern_password"
comment: good_practices_about_user_password
-d:
full: --domain
help: Domain for email and xmpp
extra:
pattern: &pattern_domain
- !!str ^([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+([^\W\d_]{2,})$
- "pattern_domain"
-q:
full: --mailbox-quota
help: Mailbox size quota
@ -157,7 +155,9 @@ user:
-m:
full: --mail
extra:
pattern: *pattern_email
pattern: &pattern_email
- !!str ^[\w.-]+@([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+([^\W\d_]{2,})$
- "pattern_email"
-p:
full: --change-password
help: New password to set
@ -419,9 +419,7 @@ domain:
domain:
help: Domain name to add
extra:
pattern: &pattern_domain
- !!str ^([^\W_A-Z]+([-]*[^\W_A-Z]+)*\.)+([^\W\d_]{2,})$
- "pattern_domain"
pattern: *pattern_domain
-d:
full: --dyndns
help: Subscribe to the DynDNS service
@ -1340,7 +1338,7 @@ dyndns:
tools:
category_help: Specific tools
actions:
### tools_adminpw()
adminpw:
action_help: Change password of admin and root users
@ -1368,9 +1366,6 @@ tools:
postinstall:
action_help: YunoHost post-install
api: POST /postinstall
configuration:
# We need to be able to run the postinstall without being authenticated, otherwise we can't run the postinstall
authenticate: false
arguments:
-d:
full: --domain
@ -1378,7 +1373,7 @@ tools:
extra:
ask: ask_main_domain
pattern: *pattern_domain
required: True
required: False
-p:
full: --password
help: YunoHost admin password

View file

@ -60,6 +60,7 @@
"apps_catalog_failed_to_download": "Unable to download the {apps_catalog} app catalog: {error}",
"apps_catalog_obsolete_cache": "The app catalog cache is empty or obsolete.",
"apps_catalog_update_success": "The application catalog has been updated!",
"ask_domain": "Choose a domain",
"ask_email": "E-mail address",
"ask_firstname": "First name",
"ask_lastname": "Last name",

View file

@ -105,7 +105,7 @@ def user_list(fields=None):
@is_unit_operation([('username', 'user')])
def user_create(operation_logger, username, firstname, lastname, mail, password,
def user_create(operation_logger, username, firstname, lastname, domain, password,
mailbox_quota="0"):
"""
Create user
@ -126,7 +126,22 @@ def user_create(operation_logger, username, firstname, lastname, mail, password,
# Ensure sufficiently complex password
assert_password_is_strong_enough("user", password)
from moulinette import msignals, msettings, m18n
from yunohost.domain import domain_list
if domain is None:
if msettings.get('interface') == 'api':
raise YunohostError('Invalide usage, specify domain argument')
else:
# On affiche les differents domaines possibles
for domain_checked in domain_list()['domains'] :
msignals.display("- {}".format(domain_checked))
domain = msignals.prompt(m18n.n('ask_domain'))
# Check that the domain exists
if domain not in domain_list()['domains']:
raise YunohostError('domain_unknown', domain)
mail=username+'@'+ domain
ldap = _get_ldap_interface()
if username in user_list()["users"]:
@ -158,10 +173,6 @@ def user_create(operation_logger, username, firstname, lastname, mail, password,
if mail in aliases:
raise YunohostError('mail_unavailable')
# Check that the mail domain exists
if mail.split("@")[1] not in domain_list()['domains']:
raise YunohostError('mail_domain_unknown', domain=mail.split("@")[1])
operation_logger.start()
# Get random UID/GID
@ -176,6 +187,7 @@ def user_create(operation_logger, username, firstname, lastname, mail, password,
# Adapt values for LDAP
fullname = '%s %s' % (firstname, lastname)
attr_dict = {
'objectClass': ['mailAccount', 'inetOrgPerson', 'posixAccount', 'userPermissionYnh'],
'givenName': [firstname],