liquid_feedback_frontend
diff app/main/index/_action/send_login.lua @ 989:5a712ec1a7f1
Added support for login name recovery by email address
| author | bsw |
|---|---|
| date | Sat Apr 20 18:51:28 2013 +0200 (2013-04-20) |
| parents | |
| children | 77873f08d94f |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/index/_action/send_login.lua Sat Apr 20 18:51:28 2013 +0200 1.3 @@ -0,0 +1,42 @@ 1.4 +--trace.disable() 1.5 + 1.6 +local email = param.get("email") 1.7 + 1.8 +local members = Member:new_selector() 1.9 + :add_where{ "notify_email = ? OR notify_email_unconfirmed = ?", email, email } 1.10 + :add_where("login_recovery_expiry ISNULL OR login_recovery_expiry < now()") 1.11 + :exec() 1.12 + 1.13 +if #members < 1 then 1.14 + return 1.15 +end 1.16 + 1.17 +local logins = {} 1.18 + 1.19 +for i, member in ipairs(members) do 1.20 + local expiry = db:query("SELECT now() + '7 days'::interval as expiry", "object").expiry 1.21 + member.login_recovery_expiry = expiry 1.22 + member:save() 1.23 + logins[#logins+1] = member.login 1.24 +end 1.25 + 1.26 +local content = slot.use_temporary(function() 1.27 + slot.put(_"Hello,\n\n") 1.28 + slot.put(_"the following login is connected to this email address:\n\n") 1.29 + for i, login in ipairs(logins) do 1.30 + slot.put(_"Login-Name: " .. login .. "\n") 1.31 + end 1.32 +end) 1.33 + 1.34 +trace.debug(content) 1.35 +if true then return end 1.36 + 1.37 +local success = net.send_mail{ 1.38 + envelope_from = config.mail_envelope_from, 1.39 + from = config.mail_from, 1.40 + reply_to = config.mail_reply_to, 1.41 + to = email, 1.42 + subject = config.mail_subject_prefix .. _"Login name request", 1.43 + content_type = "text/plain; charset=UTF-8", 1.44 + content = content 1.45 +}