diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess index 47fed69..a9ca384 100644 --- a/hooks/post_app_addaccess +++ b/hooks/post_app_addaccess @@ -12,6 +12,7 @@ if [ "$app" == __APP__ ]; then if [ "$permission" = "upload images" ]; then if [ "$added_groups" = "visitors" ]; then ynh_app_setting_delete --app=$app --key=protected_regex + ynh_app_setting_set --app=$app --key=is_public --value=1 yunohost app ssowatconf else diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess index d78cd20..8c4a928 100644 --- a/hooks/post_app_removeaccess +++ b/hooks/post_app_removeaccess @@ -15,6 +15,7 @@ if [ "$app" == __APP__ ]; then path_url=$(ynh_app_setting_get --app=$app --key=path) domain_regex=$(echo "$domain" | sed 's@-@.@g') ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" + ynh_app_setting_set --app=$app --key=is_public --value=0 yunohost app ssowatconf else diff --git a/scripts/change_url b/scripts/change_url index d107825..9fdfded 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -27,6 +27,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Loading installation settings..." --weight=2 final_path=$(ynh_app_setting_get --app=$app --key=final_path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= @@ -121,7 +122,7 @@ fi #================================================= ynh_script_progression --message="Reconfiguring SSOwat..." -if [ ! -z $(ynh_app_setting_get --app=$app --key=protected_regex) ] # Only user with a yunohost account can upload an image +if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image then # If the app is private, viewing images stays publicly accessible. if [ "$new_path" == "/" ]; then diff --git a/scripts/install b/scripts/install index 0883271..15d8a39 100644 --- a/scripts/install +++ b/scripts/install @@ -49,6 +49,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=always_encrypt --value=$always_encrypt ynh_app_setting_set --app=$app --key=overwrite_settings --value=1 diff --git a/scripts/upgrade b/scripts/upgrade index 4782583..33835d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) port=$(ynh_app_setting_get --app=$app --key=port) always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt) final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -47,6 +48,15 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 +# Fix is_public as a boolean +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 +fi + if [ ! -z "$skipped_uris" ]; then ynh_app_setting_delete --app=$app --key=skipped_uris fi @@ -263,7 +273,7 @@ ynh_script_progression --message="Upgrading permission..." if ! ynh_permission_exists --permission="upload images" then - if [ -z $(ynh_app_setting_get --app=$app --key=protected_regex) ] # Everyone can upload image + if [ $is_public -eq 1 ] # Everyone can upload image then ynh_permission_create --permission="upload images" --allowed="visitors" else # Only user with a yunohost account can upload an image