portal: more explicit errors with path

This commit is contained in:
axolotle 2023-11-11 14:51:39 +01:00
parent 587d729d60
commit d7166bf77f
2 changed files with 6 additions and 2 deletions

View file

@ -501,6 +501,7 @@
"invalid_number": "Must be a number", "invalid_number": "Must be a number",
"invalid_number_max": "Must be lesser than {max}", "invalid_number_max": "Must be lesser than {max}",
"invalid_number_min": "Must be greater than {min}", "invalid_number_min": "Must be greater than {min}",
"invalid_password": "Invalid password",
"invalid_regex": "Invalid regex:'{regex}'", "invalid_regex": "Invalid regex:'{regex}'",
"invalid_shell": "Invalid shell: {shell}", "invalid_shell": "Invalid shell: {shell}",
"ip6tables_unavailable": "You cannot play with ip6tables here. You are either in a container or your kernel does not support it", "ip6tables_unavailable": "You cannot play with ip6tables here. You are either in a container or your kernel does not support it",
@ -561,6 +562,7 @@
"log_user_permission_update": "Update accesses for permission '{}'", "log_user_permission_update": "Update accesses for permission '{}'",
"log_user_update": "Update info for user '{}'", "log_user_update": "Update info for user '{}'",
"mail_alias_remove_failed": "Could not remove e-mail alias '{mail}'", "mail_alias_remove_failed": "Could not remove e-mail alias '{mail}'",
"mail_already_exists": "Mail adress '{mail}' already exists",
"mail_domain_unknown": "Invalid e-mail address for domain '{domain}'. Please, use a domain administrated by this server.", "mail_domain_unknown": "Invalid e-mail address for domain '{domain}'. Please, use a domain administrated by this server.",
"mail_forward_remove_failed": "Could not remove e-mail forwarding '{mail}'", "mail_forward_remove_failed": "Could not remove e-mail forwarding '{mail}'",
"mail_unavailable": "This e-mail address is reserved for the admins group", "mail_unavailable": "This e-mail address is reserved for the admins group",

View file

@ -199,8 +199,10 @@ def portal_update(
try: try:
ldap_interface.validate_uniqueness({"mail": mail}) ldap_interface.validate_uniqueness({"mail": mail})
except Exception as e: except YunohostError:
raise YunohostError("user_update_failed", user=username, error=e) raise YunohostValidationError(
"mail_already_exists", mail=mail, path=f"mailalias[{index}]"
)
if domain not in domains: if domain not in domains:
raise YunohostValidationError( raise YunohostValidationError(