annotate app/main/index/_action/send_login.lua @ 1308:7ea154c9238a
Added libbsd-dev and postgresql server-dev package to list of necessary packages to be installed for compiling/running on Debian
| author |
jbe |
| date |
Thu Jun 23 03:30:57 2016 +0200 (2016-06-23) |
| parents |
130eed8f7a79 |
| children |
1c329811e47f |
| rev |
line source |
|
bsw@1003
|
1 trace.disable()
|
|
bsw@989
|
2
|
|
bsw@989
|
3 local email = param.get("email")
|
|
bsw@989
|
4
|
|
bsw@989
|
5 local members = Member:new_selector()
|
|
bsw@990
|
6 :add_where{ "split_part(notify_email, '@', 1) = split_part(?, '@', 1)", email }
|
|
bsw@990
|
7 :add_where{ "lower(split_part(notify_email, '@', 2)) = lower(split_part(?, '@', 2))", email }
|
|
bsw@989
|
8 :add_where("login_recovery_expiry ISNULL OR login_recovery_expiry < now()")
|
|
bsw@989
|
9 :exec()
|
|
bsw@989
|
10
|
|
bsw@1003
|
11 if #members > 0 then
|
|
bsw@1003
|
12
|
|
bsw@1003
|
13 local logins = {}
|
|
bsw@1003
|
14
|
|
bsw@1003
|
15 for i, member in ipairs(members) do
|
|
bsw@1003
|
16 local expiry = db:query("SELECT now() + '7 days'::interval as expiry", "object").expiry
|
|
bsw@1003
|
17 member.login_recovery_expiry = expiry
|
|
bsw@1003
|
18 member:save()
|
|
bsw@1003
|
19 logins[#logins+1] = member.login
|
|
bsw@1003
|
20 end
|
|
bsw@1003
|
21
|
|
bsw@1003
|
22 local content = slot.use_temporary(function()
|
|
bsw@1003
|
23 slot.put(_"Hello,\n\n")
|
|
bsw@1003
|
24 slot.put(_"the following login is connected to this email address:\n\n")
|
|
bsw@1003
|
25 for i, login in ipairs(logins) do
|
|
bsw@1003
|
26 slot.put(_"Login-Name: " .. login .. "\n")
|
|
bsw@1003
|
27 end
|
|
bsw@1003
|
28 end)
|
|
bsw@1003
|
29
|
|
bsw@1003
|
30 local success = net.send_mail{
|
|
bsw@1003
|
31 envelope_from = config.mail_envelope_from,
|
|
bsw@1003
|
32 from = config.mail_from,
|
|
bsw@1003
|
33 reply_to = config.mail_reply_to,
|
|
bsw@1003
|
34 to = email,
|
|
bsw@1003
|
35 subject = config.mail_subject_prefix .. _"Login name request",
|
|
bsw@1003
|
36 content_type = "text/plain; charset=UTF-8",
|
|
bsw@1003
|
37 content = content
|
|
bsw@1003
|
38 }
|
|
bsw@1003
|
39
|
|
bsw@989
|
40 end
|
|
bsw@989
|
41
|
|
bsw@990
|
42 slot.put_into("notice", _"Your request has been processed.")
|