mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
[fix] Correctly save & reload mail cache
This commit is contained in:
parent
e5e4f35223
commit
bf14b2f17f
1 changed files with 33 additions and 25 deletions
58
access.lua
58
access.lua
|
@ -491,39 +491,43 @@ function do_edit ()
|
||||||
end
|
end
|
||||||
|
|
||||||
local mail_pattern = "[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?"
|
local mail_pattern = "[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?"
|
||||||
|
local domains = conf["domains"]
|
||||||
|
local mails = {}
|
||||||
table.insert(mailalias, 1, args.mail)
|
table.insert(mailalias, 1, args.mail)
|
||||||
for k, mail in ipairs(mailalias) do
|
for k, mail in ipairs(mailalias) do
|
||||||
if mail == "" then
|
if mail ~= "" then
|
||||||
table.remove(mailalias, k)
|
if not mail:match(mail_pattern) then
|
||||||
elseif not mail:match(mail_pattern) then
|
flash("fail", "Invalid mail address: "..mail)
|
||||||
flash("fail", "Invalid mail address: "..mail)
|
|
||||||
return redirect(portal_url.."edit.html")
|
|
||||||
else
|
|
||||||
local domains = conf["domains"]
|
|
||||||
local domain_valid = false
|
|
||||||
for _, domain in ipairs(domains) do
|
|
||||||
if string.ends(mail, "@"..domain) then
|
|
||||||
domain_valid = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not domain_valid then
|
|
||||||
flash("fail", "Invalid domain for mail "..mail)
|
|
||||||
return redirect(portal_url.."edit.html")
|
return redirect(portal_url.."edit.html")
|
||||||
|
else
|
||||||
|
local domain_valid = false
|
||||||
|
for _, domain in ipairs(domains) do
|
||||||
|
if string.ends(mail, "@"..domain) then
|
||||||
|
domain_valid = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if domain_valid then
|
||||||
|
table.insert(mails, mail)
|
||||||
|
else
|
||||||
|
flash("fail", "Invalid domain for mail "..mail)
|
||||||
|
return redirect(portal_url.."edit.html")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local drops = {}
|
||||||
for k, mail in ipairs(maildrop) do
|
for k, mail in ipairs(maildrop) do
|
||||||
if mail == "" then
|
if mail ~= "" then
|
||||||
table.remove(maildrop, k)
|
if not mail:match(mail_pattern) then
|
||||||
elseif not mail:match(mail_pattern) then
|
flash("fail", "Invalid mail forward address: "..mail)
|
||||||
flash("fail", "Invalid mail forward address: "..mail)
|
return redirect(portal_url.."edit.html")
|
||||||
return redirect(portal_url.."edit.html")
|
end
|
||||||
|
table.insert(drops, mail)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(maildrop, 1, user)
|
table.insert(drops, 1, user)
|
||||||
|
|
||||||
local dn = conf["ldap_identifier"].."="..user..","..conf["ldap_group"]
|
local dn = conf["ldap_identifier"].."="..user..","..conf["ldap_group"]
|
||||||
local ldap = lualdap.open_simple(conf["ldap_host"], dn, cache:get(user.."-password"))
|
local ldap = lualdap.open_simple(conf["ldap_host"], dn, cache:get(user.."-password"))
|
||||||
|
@ -531,10 +535,14 @@ function do_edit ()
|
||||||
if ldap:modify(dn, {'=', cn = cn,
|
if ldap:modify(dn, {'=', cn = cn,
|
||||||
givenName = args.givenName,
|
givenName = args.givenName,
|
||||||
sn = args.sn,
|
sn = args.sn,
|
||||||
mail = mailalias,
|
mail = mails,
|
||||||
maildrop = maildrop })
|
maildrop = drops })
|
||||||
then
|
then
|
||||||
cache:delete(user.."-"..conf["ldap_identifier"])
|
cache:delete(user.."-"..conf["ldap_identifier"])
|
||||||
|
for _, v in ipairs({2, 3, 4, 5, 6, 7, 8, 9, 10}) do
|
||||||
|
cache:delete(user.."-maildrop|"..v)
|
||||||
|
cache:delete(user.."-mail|"..v)
|
||||||
|
end
|
||||||
set_headers(user) -- Ugly trick to reload cache
|
set_headers(user) -- Ugly trick to reload cache
|
||||||
flash("win", "Informations updated")
|
flash("win", "Informations updated")
|
||||||
return redirect(portal_url.."info.html")
|
return redirect(portal_url.."info.html")
|
||||||
|
|
Loading…
Add table
Reference in a new issue