Merge pull request #868 from kay0u/fix-legacy-permission-management

fix legacy permission management
This commit is contained in:
Kayou 2020-02-25 17:18:33 +01:00 committed by GitHub
commit f0ef8aca79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -158,6 +158,11 @@ ynh_add_protected_uris() {
# #
ynh_app_setting() ynh_app_setting()
{ {
if [[ "$1" == "delete" ]] && [[ "$3" =~ ^(unprotected|skipped)_ ]]
then
current_value=$(ynh_app_setting_get --app=$app --key=$3)
fi
ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python2.7 - <<EOF ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python2.7 - <<EOF
import os, yaml, sys import os, yaml, sys
app, action = os.environ['APP'], os.environ['ACTION'].lower() app, action = os.environ['APP'], os.environ['ACTION'].lower()
@ -187,9 +192,15 @@ EOF
# Fucking legacy permission management. # Fucking legacy permission management.
# We need this because app temporarily set the app as unprotected to configure it with curl... # We need this because app temporarily set the app as unprotected to configure it with curl...
if [[ "$3" =~ ^(unprotected|skipped)_ ]] && [[ "${4:-}" == "/" ]] if [[ "$3" =~ ^(unprotected|skipped)_ ]]
then then
ynh_permission_update --permission "main" --add "visitors" if [[ "$1" == "set" ]] && [[ "${4:-}" == "/" ]]
then
ynh_permission_update --permission "main" --add "visitors"
elif [[ "$1" == "delete" ]] && [[ "${current_value:-}" == "/" ]]
then
ynh_permission_update --permission "main" --remove "visitors"
fi
fi fi
} }