mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
[fix] Load modules as proper modules + typo
This commit is contained in:
parent
7a86897579
commit
2a9769f7d9
3 changed files with 21 additions and 20 deletions
|
@ -125,7 +125,7 @@ then
|
||||||
|
|
||||||
-- If all the previous cases have failed, redirect to portal
|
-- If all the previous cases have failed, redirect to portal
|
||||||
else
|
else
|
||||||
hlp.flash("info", t("please_login"))
|
hlp.flash("info", hlp.t("please_login"))
|
||||||
return hlp.redirect(conf.portal_url)
|
return hlp.redirect(conf.portal_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ then
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Redirect to portal
|
-- Redirect to portal
|
||||||
hlp.flash("fail", t("please_login_from_portal"))
|
hlp.flash("fail", hlp.t("please_login_from_portal"))
|
||||||
return hlp.redirect(conf.portal_url)
|
return hlp.redirect(conf.portal_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -357,6 +357,6 @@ end
|
||||||
-- The default is to protect every URL by default.
|
-- The default is to protect every URL by default.
|
||||||
--
|
--
|
||||||
|
|
||||||
hlp.flash("info", t("please_login"))
|
hlp.flash("info", hlp.t("please_login"))
|
||||||
local back_url = ngx.var.scheme .. "://" .. ngx.var.host .. ngx.var.uri .. hlp.uri_args_string()
|
local back_url = ngx.var.scheme .. "://" .. ngx.var.host .. ngx.var.uri .. hlp.uri_args_string()
|
||||||
return hlp.redirect(conf.portal_url.."?r="..ngx.encode_base64(back_url))
|
return hlp.redirect(conf.portal_url.."?r="..ngx.encode_base64(back_url))
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
-- This file loads the configuration from config files or default values.
|
-- This file loads the configuration from config files or default values.
|
||||||
--
|
--
|
||||||
|
|
||||||
|
module('config', package.seeall)
|
||||||
|
|
||||||
function get_config ()
|
function get_config ()
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ function get_config ()
|
||||||
conf.lang = ngx.req.get_headers()["Accept-Language"]
|
conf.lang = ngx.req.get_headers()["Accept-Language"]
|
||||||
|
|
||||||
if conf.lang then
|
if conf.lang then
|
||||||
conf.lang = string.sub(lang, 1, 2)
|
conf.lang = string.sub(conf.lang, 1, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
|
32
helpers.lua
32
helpers.lua
|
@ -5,6 +5,7 @@
|
||||||
-- a set of useful functions related to HTTP and LDAP.
|
-- a set of useful functions related to HTTP and LDAP.
|
||||||
--
|
--
|
||||||
|
|
||||||
|
module('helpers', package.seeall)
|
||||||
|
|
||||||
-- Read a FS stored file
|
-- Read a FS stored file
|
||||||
function read_file(file)
|
function read_file(file)
|
||||||
|
@ -422,22 +423,6 @@ end
|
||||||
-- title, the flash notifications' content and the translated strings.
|
-- title, the flash notifications' content and the translated strings.
|
||||||
function get_data_for(view)
|
function get_data_for(view)
|
||||||
local user = ngx.var.cookie_SSOwAuthUser
|
local user = ngx.var.cookie_SSOwAuthUser
|
||||||
local data = {}
|
|
||||||
|
|
||||||
-- Pass all the translated strings to the view (to use with t_<key>)
|
|
||||||
if conf.lang and i18n[conf.lang] then
|
|
||||||
translate_table = i18n[conf.lang]
|
|
||||||
else
|
|
||||||
translate_table = i18n[conf["default_language"]]
|
|
||||||
end
|
|
||||||
for k, v in pairs(translate_table) do
|
|
||||||
data["t_"..k] = v
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Pass flash notification content
|
|
||||||
data['flash_fail'] = {flashs["fail"]}
|
|
||||||
data['flash_win'] = {flashs["win"] }
|
|
||||||
data['flash_info'] = {flashs["info"]}
|
|
||||||
|
|
||||||
-- For the login page we only need the page title
|
-- For the login page we only need the page title
|
||||||
if view == "login.html" then
|
if view == "login.html" then
|
||||||
|
@ -478,6 +463,21 @@ function get_data_for(view)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Pass all the translated strings to the view (to use with t_<key>)
|
||||||
|
if conf.lang and i18n[conf.lang] then
|
||||||
|
translate_table = i18n[conf.lang]
|
||||||
|
else
|
||||||
|
translate_table = i18n[conf["default_language"]]
|
||||||
|
end
|
||||||
|
for k, v in pairs(translate_table) do
|
||||||
|
data["t_"..k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Pass flash notification content
|
||||||
|
data['flash_fail'] = {flashs["fail"]}
|
||||||
|
data['flash_win'] = {flashs["win"] }
|
||||||
|
data['flash_info'] = {flashs["info"]}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue