better migration to the new permission process

This commit is contained in:
Kay0u 2020-03-30 19:07:55 +02:00
parent 86d348b312
commit 65e0c8e926
No known key found for this signature in database
GPG Key ID: AE1DCADB6415A156

View File

@ -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
#=================================================