mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Drop deprecated firstname/lastname in user_create/update + also drop old deprecated cert- commands
This commit is contained in:
parent
f6ab380730
commit
8ac48ee09e
4 changed files with 17 additions and 115 deletions
|
@ -70,26 +70,10 @@ user:
|
||||||
help: The full name of the user. For example 'Camille Dupont'
|
help: The full name of the user. For example 'Camille Dupont'
|
||||||
extra:
|
extra:
|
||||||
ask: ask_fullname
|
ask: ask_fullname
|
||||||
required: False
|
required: True
|
||||||
pattern: &pattern_fullname
|
pattern: &pattern_fullname
|
||||||
- !!str ^([^\W_]{1,30}[ ,.'-]{0,3})+$
|
- !!str ^([^\W_]{1,30}[ ,.'-]{0,3})+$
|
||||||
- "pattern_fullname"
|
- "pattern_fullname"
|
||||||
-f:
|
|
||||||
full: --firstname
|
|
||||||
help: Deprecated. Use --fullname instead.
|
|
||||||
extra:
|
|
||||||
required: False
|
|
||||||
pattern: &pattern_firstname
|
|
||||||
- !!str ^([^\W\d_]{1,30}[ ,.'-]{0,3})+$
|
|
||||||
- "pattern_firstname"
|
|
||||||
-l:
|
|
||||||
full: --lastname
|
|
||||||
help: Deprecated. Use --fullname instead.
|
|
||||||
extra:
|
|
||||||
required: False
|
|
||||||
pattern: &pattern_lastname
|
|
||||||
- !!str ^([^\W\d_]{1,30}[ ,.'-]{0,3})+$
|
|
||||||
- "pattern_lastname"
|
|
||||||
-p:
|
-p:
|
||||||
full: --password
|
full: --password
|
||||||
help: User password
|
help: User password
|
||||||
|
@ -147,16 +131,6 @@ user:
|
||||||
help: The full name of the user. For example 'Camille Dupont'
|
help: The full name of the user. For example 'Camille Dupont'
|
||||||
extra:
|
extra:
|
||||||
pattern: *pattern_fullname
|
pattern: *pattern_fullname
|
||||||
-f:
|
|
||||||
full: --firstname
|
|
||||||
help: Deprecated. Use --fullname instead.
|
|
||||||
extra:
|
|
||||||
pattern: *pattern_firstname
|
|
||||||
-l:
|
|
||||||
full: --lastname
|
|
||||||
help: Deprecated. Use --fullname instead.
|
|
||||||
extra:
|
|
||||||
pattern: *pattern_lastname
|
|
||||||
-m:
|
-m:
|
||||||
full: --mail
|
full: --mail
|
||||||
extra:
|
extra:
|
||||||
|
@ -551,54 +525,6 @@ domain:
|
||||||
extra:
|
extra:
|
||||||
pattern: *pattern_domain
|
pattern: *pattern_domain
|
||||||
|
|
||||||
### certificate_status()
|
|
||||||
cert-status:
|
|
||||||
deprecated: true
|
|
||||||
action_help: List status of current certificates (all by default).
|
|
||||||
arguments:
|
|
||||||
domain_list:
|
|
||||||
help: Domains to check
|
|
||||||
nargs: "*"
|
|
||||||
--full:
|
|
||||||
help: Show more details
|
|
||||||
action: store_true
|
|
||||||
|
|
||||||
### certificate_install()
|
|
||||||
cert-install:
|
|
||||||
deprecated: true
|
|
||||||
action_help: Install Let's Encrypt certificates for given domains (all by default).
|
|
||||||
arguments:
|
|
||||||
domain_list:
|
|
||||||
help: Domains for which to install the certificates
|
|
||||||
nargs: "*"
|
|
||||||
--force:
|
|
||||||
help: Install even if current certificate is not self-signed
|
|
||||||
action: store_true
|
|
||||||
--no-checks:
|
|
||||||
help: Does not perform any check that your domain seems correctly configured (DNS, reachability) before attempting to install. (Not recommended)
|
|
||||||
action: store_true
|
|
||||||
--self-signed:
|
|
||||||
help: Install self-signed certificate instead of Let's Encrypt
|
|
||||||
action: store_true
|
|
||||||
|
|
||||||
### certificate_renew()
|
|
||||||
cert-renew:
|
|
||||||
deprecated: true
|
|
||||||
action_help: Renew the Let's Encrypt certificates for given domains (all by default).
|
|
||||||
arguments:
|
|
||||||
domain_list:
|
|
||||||
help: Domains for which to renew the certificates
|
|
||||||
nargs: "*"
|
|
||||||
--force:
|
|
||||||
help: Ignore the validity threshold (30 days)
|
|
||||||
action: store_true
|
|
||||||
--email:
|
|
||||||
help: Send an email to root with logs if some renewing fails
|
|
||||||
action: store_true
|
|
||||||
--no-checks:
|
|
||||||
help: Does not perform any check that your domain seems correctly configured (DNS, reachability) before attempting to renew. (Not recommended)
|
|
||||||
action: store_true
|
|
||||||
|
|
||||||
### domain_url_available()
|
### domain_url_available()
|
||||||
url-available:
|
url-available:
|
||||||
hide_in_help: True
|
hide_in_help: True
|
||||||
|
|
|
@ -154,11 +154,12 @@ def domain_info(domain):
|
||||||
|
|
||||||
from yunohost.app import app_info
|
from yunohost.app import app_info
|
||||||
from yunohost.dns import _get_registar_settings
|
from yunohost.dns import _get_registar_settings
|
||||||
|
from yunohost.certificate import certificate_status
|
||||||
|
|
||||||
_assert_domain_exists(domain)
|
_assert_domain_exists(domain)
|
||||||
|
|
||||||
registrar, _ = _get_registar_settings(domain)
|
registrar, _ = _get_registar_settings(domain)
|
||||||
certificate = domain_cert_status([domain], full=True)["certificates"][domain]
|
certificate = certificate_status([domain], full=True)["certificates"][domain]
|
||||||
|
|
||||||
apps = []
|
apps = []
|
||||||
for app in _installed_apps():
|
for app in _installed_apps():
|
||||||
|
|
|
@ -263,12 +263,6 @@ def test_del_group_that_does_not_exist(mocker):
|
||||||
|
|
||||||
|
|
||||||
def test_update_user():
|
def test_update_user():
|
||||||
with message("user_updated"):
|
|
||||||
user_update("alice", firstname="NewName", lastname="NewLast")
|
|
||||||
|
|
||||||
info = user_info("alice")
|
|
||||||
assert info["fullname"] == "NewName NewLast"
|
|
||||||
|
|
||||||
with message("user_updated"):
|
with message("user_updated"):
|
||||||
user_update("alice", fullname="New2Name New2Last")
|
user_update("alice", fullname="New2Name New2Last")
|
||||||
|
|
||||||
|
@ -315,7 +309,7 @@ def test_update_group_remove_user_not_already_in():
|
||||||
|
|
||||||
def test_update_user_that_doesnt_exist(mocker):
|
def test_update_user_that_doesnt_exist(mocker):
|
||||||
with raiseYunohostError(mocker, "user_unknown"):
|
with raiseYunohostError(mocker, "user_unknown"):
|
||||||
user_update("doesnt_exist", firstname="NewName", lastname="NewLast")
|
user_update("doesnt_exist", fullname="Foo Bar")
|
||||||
|
|
||||||
|
|
||||||
def test_update_group_that_doesnt_exist(mocker):
|
def test_update_group_that_doesnt_exist(mocker):
|
||||||
|
|
45
src/user.py
45
src/user.py
|
@ -141,33 +141,20 @@ def user_create(
|
||||||
domain,
|
domain,
|
||||||
password,
|
password,
|
||||||
fullname=None,
|
fullname=None,
|
||||||
firstname=None,
|
|
||||||
lastname=None,
|
|
||||||
mailbox_quota="0",
|
mailbox_quota="0",
|
||||||
admin=False,
|
admin=False,
|
||||||
from_import=False,
|
from_import=False,
|
||||||
loginShell=None,
|
loginShell=None,
|
||||||
):
|
):
|
||||||
if firstname or lastname:
|
|
||||||
logger.warning(
|
|
||||||
"Options --firstname / --lastname of 'yunohost user create' are deprecated. We recommend using --fullname instead."
|
|
||||||
)
|
|
||||||
|
|
||||||
if not fullname or not fullname.strip():
|
if not fullname or not fullname.strip():
|
||||||
if not firstname.strip():
|
raise YunohostValidationError(
|
||||||
raise YunohostValidationError(
|
"You should specify the fullname of the user using option -F"
|
||||||
"You should specify the fullname of the user using option -F"
|
)
|
||||||
)
|
fullname = fullname.strip()
|
||||||
lastname = (
|
firstname = fullname.split()[0]
|
||||||
lastname or " "
|
lastname = (
|
||||||
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
|
" ".join(fullname.split()[1:]) or " "
|
||||||
fullname = f"{firstname} {lastname}".strip()
|
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
|
||||||
else:
|
|
||||||
fullname = fullname.strip()
|
|
||||||
firstname = fullname.split()[0]
|
|
||||||
lastname = (
|
|
||||||
" ".join(fullname.split()[1:]) or " "
|
|
||||||
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
|
|
||||||
|
|
||||||
from yunohost.domain import domain_list, _get_maindomain, _assert_domain_exists
|
from yunohost.domain import domain_list, _get_maindomain, _assert_domain_exists
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
|
@ -364,8 +351,6 @@ def user_delete(operation_logger, username, purge=False, from_import=False):
|
||||||
def user_update(
|
def user_update(
|
||||||
operation_logger,
|
operation_logger,
|
||||||
username,
|
username,
|
||||||
firstname=None,
|
|
||||||
lastname=None,
|
|
||||||
mail=None,
|
mail=None,
|
||||||
change_password=None,
|
change_password=None,
|
||||||
add_mailforward=None,
|
add_mailforward=None,
|
||||||
|
@ -377,17 +362,15 @@ def user_update(
|
||||||
fullname=None,
|
fullname=None,
|
||||||
loginShell=None,
|
loginShell=None,
|
||||||
):
|
):
|
||||||
if firstname or lastname:
|
|
||||||
logger.warning(
|
|
||||||
"Options --firstname / --lastname of 'yunohost user create' are deprecated. We recommend using --fullname instead."
|
|
||||||
)
|
|
||||||
|
|
||||||
if fullname and fullname.strip():
|
if fullname and fullname.strip():
|
||||||
fullname = fullname.strip()
|
fullname = fullname.strip()
|
||||||
firstname = fullname.split()[0]
|
firstname = fullname.split()[0]
|
||||||
lastname = (
|
lastname = (
|
||||||
" ".join(fullname.split()[1:]) or " "
|
" ".join(fullname.split()[1:]) or " "
|
||||||
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
|
) # Stupid hack because LDAP requires the sn/lastname attr, but it accepts a single whitespace...
|
||||||
|
else:
|
||||||
|
firstname = None
|
||||||
|
lastname = None
|
||||||
|
|
||||||
from yunohost.domain import domain_list
|
from yunohost.domain import domain_list
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
@ -884,8 +867,7 @@ def user_import(operation_logger, csvfile, update=False, delete=False):
|
||||||
|
|
||||||
user_update(
|
user_update(
|
||||||
new_infos["username"],
|
new_infos["username"],
|
||||||
firstname=new_infos["firstname"],
|
fullname=(new_infos["firstname"] + " " + new_infos["lastname"]).strip(),
|
||||||
lastname=new_infos["lastname"],
|
|
||||||
change_password=new_infos["password"],
|
change_password=new_infos["password"],
|
||||||
mailbox_quota=new_infos["mailbox-quota"],
|
mailbox_quota=new_infos["mailbox-quota"],
|
||||||
mail=new_infos["mail"],
|
mail=new_infos["mail"],
|
||||||
|
@ -930,8 +912,7 @@ def user_import(operation_logger, csvfile, update=False, delete=False):
|
||||||
user["password"],
|
user["password"],
|
||||||
user["mailbox-quota"],
|
user["mailbox-quota"],
|
||||||
from_import=True,
|
from_import=True,
|
||||||
firstname=user["firstname"],
|
fullname=(user["firstname"] + " " + user["lastname"]).strip(),
|
||||||
lastname=user["lastname"],
|
|
||||||
)
|
)
|
||||||
update(user)
|
update(user)
|
||||||
result["created"] += 1
|
result["created"] += 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue