From 6e5e118bcfda01b606c8d60b6f6fe12bcc5b0560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Sat, 4 Apr 2020 00:14:47 +0200 Subject: [PATCH] Set mandatory domain and path to add url in permission --- locales/en.json | 1 + src/yunohost/permission.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index 42ed6d7ff..564c0b821 100644 --- a/locales/en.json +++ b/locales/en.json @@ -578,6 +578,7 @@ "tools_upgrade_special_packages_completed": "YunoHost package upgrade completed.\nPress [Enter] to get the command line back", "unbackup_app": "App '{app:s}' will not be saved", "unexpected_error": "Something unexpected went wrong: {error}", + "unknown_main_domain_path": "Unknown domain or path for app '{app}'. You need to specify a domain and a path to be able to specify a url for permission.", "unlimit": "No quota", "unrestore_app": "App '{app:s}' will not be restored", "update_apt_cache_failed": "Could not to update the cache of APT (Debian's package manager). Here is a dump of the sources.list lines, which might help identify problematic lines: \n{sourceslist}", diff --git a/src/yunohost/permission.py b/src/yunohost/permission.py index 39da59bd4..29872d044 100644 --- a/src/yunohost/permission.py +++ b/src/yunohost/permission.py @@ -341,8 +341,12 @@ def permission_url(operation_logger, permission, if "." not in permission: permission = permission + ".main" - # App main path in setting to manage conflict - app_main_path = app_setting(permission.split('.')[0], 'domain') + app_setting(permission.split('.')[0], 'path') + if url or add_url: + if app_setting(permission.split('.')[0], 'domain') is None or app_setting(permission.split('.')[0], 'path') is None: + raise YunohostError('unknown_main_domain_path', app=permission.split('.')[0]) + else: + # App main path in setting to manage conflict + app_main_path = app_setting(permission.split('.')[0], 'domain') + app_setting(permission.split('.')[0], 'path') # Fetch existing permission