dyndns: switch to ValidationError for some service response

This commit is contained in:
axolotle 2023-09-24 17:19:24 +02:00
parent 322fc3b712
commit 67e28567ff
2 changed files with 6 additions and 2 deletions

View file

@ -91,6 +91,7 @@
"ask_new_path": "New path",
"ask_password": "Password",
"ask_dyndns_recovery_password_explain": "Please pick a recovery password for your DynDNS domain, in case you need to reset it later.",
"ask_dyndns_recovery_password_explain_unavailable": "This DynDNS domain is not available, please enter the recovery password if this your domain.",
"ask_dyndns_recovery_password": "DynDNS recovery password",
"ask_dyndns_recovery_password_explain_during_unsubscribe": "Please enter the recovery password for this DynDNS domain.",
"ask_user_domain": "Domain to use for the user's email address and XMPP account",
@ -411,6 +412,7 @@
"dyndns_unsubscribed": "DynDNS domain unsubscribed",
"dyndns_unsubscribe_denied": "Failed to unsubscribe domain: invalid credentials",
"dyndns_unsubscribe_already_unsubscribed": "Domain is already unsubscribed",
"dyndns_unsubscribe_too_many_requests": "YunoHost's free domain service received too many requests from you, wait 1 hour or so before trying again.",
"dyndns_set_recovery_password_denied": "Failed to set recovery password: invalid key",
"dyndns_set_recovery_password_unknown_domain": "Failed to set recovery password: domain not registered",
"dyndns_set_recovery_password_invalid_password": "Failed to set recovery password: password is not strong enough",

View file

@ -273,9 +273,11 @@ def dyndns_unsubscribe(operation_logger, domain, recovery_password=None):
# in /etc/yunohost/dyndns
regen_conf(["yunohost"])
elif r.status_code == 403:
raise YunohostError("dyndns_unsubscribe_denied")
raise YunohostValidationError("dyndns_unsubscribe_denied")
elif r.status_code == 409:
raise YunohostError("dyndns_unsubscribe_already_unsubscribed")
raise YunohostValidationError("dyndns_unsubscribe_already_unsubscribed")
elif r.status_code == 429:
raise YunohostValidationError("dyndns_unsubscribe_too_many_requests")
else:
raise YunohostError(
"dyndns_unsubscribe_failed",