From 14237a512dfc2546764e2848411e1e389c8e73e4 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sat, 14 Aug 2021 15:21:08 +0200 Subject: [PATCH] tmp fix ynh_permission_has_user --- manifest.json | 2 +- scripts/_ynh_permission_has_user.sh | 28 ++++++++++++++++++++++++++++ scripts/upgrade | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 scripts/_ynh_permission_has_user.sh diff --git a/manifest.json b/manifest.json index 7bb9686..6ad59f3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "CMS with a focus on collaborative edition and multilingualism", "fr": "CMS conçu pour l'édition collaborative et le multilinguisme" }, - "version": "4.0.0~ynh1", + "version": "4.0.0~ynh2", "url": "http://www.spip.net/", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/_ynh_permission_has_user.sh b/scripts/_ynh_permission_has_user.sh new file mode 100644 index 0000000..ae04fbc --- /dev/null +++ b/scripts/_ynh_permission_has_user.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +ynh_permission_has_user() { + local legacy_args=pu + # Declare an array to define the options of this helper. + local -A args_array=( [p]=permission= [u]=user= ) + local permission + local user + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if ! ynh_permission_exists --permission=$permission + then + return 1 + fi + + # Check both allowed and corresponding_users sections in the json + for section in "allowed" "corresponding_users" + do + if yunohost user permission info "$app.$permission" --output-as json --quiet \ + | jq -e --arg user $user --arg section $section '.[$section] | index($user)' >/dev/null + then + return 0 + fi + done + + return 1 +} \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 2fb6f35..27143e2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,6 +8,7 @@ source _common.sh source /usr/share/yunohost/helpers +source _ynh_permission_has_user.sh #================================================= # LOAD SETTINGS