provide more details about apps to template

This commit is contained in:
Ludovic Coues 2016-05-11 15:37:16 +02:00
parent cdce27fc5d
commit 9e413af693
2 changed files with 27 additions and 12 deletions

View file

@ -17,14 +17,26 @@
"Email": "mail", "Email": "mail",
"Name": "cn" "Name": "cn"
}, },
"users": { "apps": {
"myuser": { "app_id": {
"example.com/myapp": "My App", "id": "app_id",
"example.com/myapp2": "My second App" "name": "App Name",
"url": "example.com/app",
"description": "The app description"
}, },
"myuser2": { "second_app": {
"example.org/myapp": "My other domain App", "id": "second_app",
"example.com/myapp2": "My second App" "name": "Another App",
"url": "example.org/that"
} }
},
"users": {
"myuser": [
"app_id",
"second_app"
],
"myuser2": [
"app_id"
]
} }
} }

View file

@ -208,8 +208,10 @@ function has_access(user, url)
end end
-- Loop through user's ACLs and return if the URL is authorized. -- Loop through user's ACLs and return if the URL is authorized.
for u, _ in pairs(conf["users"][user]) do for _, app_id in pairs(conf["users"][user]) do
-- Get the url from the apps list
u = conf["apps"][app_id]["url"]
-- Replace the original domain by a local one if you are connected from -- Replace the original domain by a local one if you are connected from
-- a non-global domain name. -- a non-global domain name.
if ngx.var.host == conf["local_portal_domain"] then if ngx.var.host == conf["local_portal_domain"] then
@ -491,14 +493,15 @@ function get_data_for(view)
-- Add user's accessible URLs using the ACLs. -- Add user's accessible URLs using the ACLs.
-- It is typically used to build the app list. -- It is typically used to build the app list.
for url, name in pairs(conf["users"][user]) do for _, app_id in pairs(conf["users"][user]) do
app = conf["apps"][app_id]
if ngx.var.host == conf["local_portal_domain"] then if ngx.var.host == conf["local_portal_domain"] then
url = string.gsub(url, conf["original_portal_domain"], conf["local_portal_domain"]) app["url"] = string.gsub(app["url"], conf["original_portal_domain"], conf["local_portal_domain"])
end end
table.insert(sorted_apps, name) table.insert(sorted_apps, app_id)
table.sort(sorted_apps) table.sort(sorted_apps)
table.insert(data["app"], index_of(sorted_apps, name), { url = url, name = name }) table.insert(data["app"], index_of(sorted_apps, app_id), app)
end end
end end