mirror of
https://github.com/YunoHost-Apps/grav_ynh.git
synced 2024-09-03 19:16:01 +02:00
[rem] ynh_permission_has_user is now official
This commit is contained in:
parent
c3ad21a0a9
commit
4da1227ef5
4 changed files with 2 additions and 42 deletions
|
@ -27,9 +27,7 @@
|
|||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# doable, but there is no group in YunoHost's LDAP
|
||||
# https://github.com/trilbymedia/grav-plugin-login-ldap
|
||||
Level 4=1
|
||||
Level 4=auto
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"email": "lithrel@randomdomainname.net"
|
||||
}],
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.7"
|
||||
"yunohost": ">= 3.7.1"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 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.
|
||||
|
||||
# Check if a permission exists
|
||||
#
|
||||
# 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"
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source experimental_helpers/ynh_permission_has_user
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue