From 65e0c8e92623c50c25fffb27c53f495a6bd4bc8f Mon Sep 17 00:00:00 2001 From: Kay0u Date: Mon, 30 Mar 2020 19:07:55 +0200 Subject: [PATCH] better migration to the new permission process --- scripts/upgrade | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 19a361c..97815e3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -52,33 +52,26 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -# If nobody installed your app before 3.7, then you may -# safely remove these lines +### If nobody installed your app before 3.7, +### then you may safely remove these lines # Cleaning legacy permissions is_public=$(ynh_app_setting_get --app=$app --key=is_public) -skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) -unprotected_uris=$(ynh_app_setting_get --app=$app --key=unprotected_uris) -protected_uris=$(ynh_app_setting_get --app=$app --key=protected_uris) -# Remove is_public if exists -if [ ! -z "$is_public" ]; then - ynh_app_setting_delete --app=$app --key=is_public -fi - -# Remove skipped_uris if exists -if [ ! -z "$skipped_uris" ]; then +if [ -n "$is_public" ]; then + # Remove skipped_uris ynh_app_setting_delete --app=$app --key=skipped_uris -fi - -# Remove unprotected_uris if exists -if [ ! -z "$unprotected_uris" ]; then + # Remove unprotected_uris ynh_app_setting_delete --app=$app --key=unprotected_uris -fi - -# Remove protected_uris if exists -if [ ! -z "$protected_uris" ]; then + # Remove protected_uris ynh_app_setting_delete --app=$app --key=protected_uris + + # Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7 + # If the app was public, add visitors again to the main permission + if [ $is_public -eq 1 ]; then + ynh_permission_update --permission "main" --add "visitors" + fi + ynh_app_setting_delete --app=$app --key=is_public fi #=================================================