1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hextris_ynh.git synced 2024-09-03 19:16:05 +02:00

remove ynh_permission_has_user

! ynh_permission_has_user is now an official helper since version '3.7.1'
This commit is contained in:
yalh76 2020-06-02 23:12:59 +02:00
parent 767ebdff77
commit c68fbb0f51
2 changed files with 1 additions and 35 deletions

View file

@ -14,7 +14,7 @@
"email": "aeris@e.email" "email": "aeris@e.email"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.7.0" "yunohost": ">= 3.7.1"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [

View file

@ -16,37 +16,3 @@
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================
# Check if a permission exists
#
# While waiting for this new helper https://github.com/YunoHost/yunohost/pull/905
# We have to use another one because the new helper use a new YunoHost command, not available for now.
#
# usage: ynh_permission_has_user --permission=permission --user=user
# | arg: -p, --permission - the permission to check
# | arg: -u, --user - the user seek in the permission
#
# example: ynh_permission_has_user --permission=main --user=visitors
#
# Requires YunoHost version 3.7.1 or higher.
ynh_permission_has_user() {
local legacy_args=pu
# Declare an array to define the options of this helper.
declare -Ar 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
# List all permissions
# Filter only the required permission with a multiline sed (Here a cut from the permission to the next one), remove the url and his value
perm="$(yunohost user permission list --full --output-as plain | sed --quiet "/^#$app.$permission/,/^#[[:alnum:]]/p" | sed "/^##url/,+1d")"
# Remove all lines starting by # (got from the plain output before)
allowed_users="$(echo "$perm" | grep --invert-match '^#')"
# Grep the list of users an return the result if the user is indeed into the list
echo "$allowed_users" | grep --quiet --word "$user"
}