liquid_feedback_frontend

changeset 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 81bde33c2256
children 77873f08d94f
files app/main/_filter/21_auth.lua app/main/_filter_view/30_navigation.lua app/main/index/_action/send_login.lua app/main/index/login.lua app/main/index/reset_password.lua app/main/index/send_login.lua
line diff
     1.1 --- a/app/main/_filter/21_auth.lua	Sat Apr 20 18:40:34 2013 +0200
     1.2 +++ b/app/main/_filter/21_auth.lua	Sat Apr 20 18:51:28 2013 +0200
     1.3 @@ -13,6 +13,8 @@
     1.4      or view   == "about"
     1.5      or view   == "reset_password"
     1.6      or action == "reset_password"
     1.7 +    or view   == "send_login"
     1.8 +    or action == "send_login"
     1.9      or view   == "confirm_notify_email"
    1.10      or action == "confirm_notify_email"
    1.11      or view   == "menu"
     2.1 --- a/app/main/_filter_view/30_navigation.lua	Sat Apr 20 18:40:34 2013 +0200
     2.2 +++ b/app/main/_filter_view/30_navigation.lua	Sat Apr 20 18:51:28 2013 +0200
     2.3 @@ -39,11 +39,6 @@
     2.4        module = 'index',
     2.5        view   = 'register'
     2.6      }
     2.7 -    ui.link{
     2.8 -      text   = _"Reset password",
     2.9 -      module = 'index',
    2.10 -      view   = 'reset_password'
    2.11 -    }
    2.12    end
    2.13  end)
    2.14  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/app/main/index/_action/send_login.lua	Sat Apr 20 18:51:28 2013 +0200
     3.3 @@ -0,0 +1,42 @@
     3.4 +--trace.disable()
     3.5 +
     3.6 +local email = param.get("email")
     3.7 +
     3.8 +local members = Member:new_selector()
     3.9 +  :add_where{ "notify_email = ? OR notify_email_unconfirmed = ?", email, email }
    3.10 +  :add_where("login_recovery_expiry ISNULL OR login_recovery_expiry < now()")
    3.11 +  :exec()
    3.12 +
    3.13 +if #members < 1 then
    3.14 +  return
    3.15 +end
    3.16 +  
    3.17 +local logins = {}
    3.18 +
    3.19 +for i, member in ipairs(members) do
    3.20 +  local expiry = db:query("SELECT now() + '7 days'::interval as expiry", "object").expiry
    3.21 +  member.login_recovery_expiry = expiry
    3.22 +  member:save()
    3.23 +  logins[#logins+1] = member.login
    3.24 +end
    3.25 +
    3.26 +local content = slot.use_temporary(function()
    3.27 +  slot.put(_"Hello,\n\n")
    3.28 +  slot.put(_"the following login is connected to this email address:\n\n")
    3.29 +  for i, login in ipairs(logins) do
    3.30 +    slot.put(_"Login-Name: " .. login .. "\n")
    3.31 +  end
    3.32 +end)
    3.33 +
    3.34 +trace.debug(content)
    3.35 +if true then return end
    3.36 +
    3.37 +local success = net.send_mail{
    3.38 +  envelope_from = config.mail_envelope_from,
    3.39 +  from          = config.mail_from,
    3.40 +  reply_to      = config.mail_reply_to,
    3.41 +  to            = email,
    3.42 +  subject       = config.mail_subject_prefix .. _"Login name request",
    3.43 +  content_type  = "text/plain; charset=UTF-8",
    3.44 +  content       = content
    3.45 +}
     4.1 --- a/app/main/index/login.lua	Sat Apr 20 18:40:34 2013 +0200
     4.2 +++ b/app/main/index/login.lua	Sat Apr 20 18:51:28 2013 +0200
     4.3 @@ -5,7 +5,7 @@
     4.4    end
     4.5  }
     4.6  
     4.7 -execute.view{ module = "index", view = "_lang_chooser" }
     4.8 +ui.actions()
     4.9  
    4.10  ui.title(_"Login")
    4.11  app.html_title.title = _"Login"
    4.12 @@ -62,5 +62,7 @@
    4.13      ui.submit{
    4.14        text = _'Login'
    4.15      }
    4.16 +    slot.put("&nbsp;&nbsp;")
    4.17 +    ui.link{ module = "index", view = "reset_password", text = _"Forgot password?" }
    4.18    end
    4.19  }
     5.1 --- a/app/main/index/reset_password.lua	Sat Apr 20 18:40:34 2013 +0200
     5.2 +++ b/app/main/index/reset_password.lua	Sat Apr 20 18:51:28 2013 +0200
     5.3 @@ -1,15 +1,14 @@
     5.4  execute.view{ module = "index", view = "_lang_chooser" }
     5.5  
     5.6 -slot.put_into("title", _"Reset password")
     5.7 +ui.title(_"Reset password")
     5.8  
     5.9 -slot.select("actions", function()
    5.10 +ui.actions(function()
    5.11    ui.link{
    5.12      content = function()
    5.13 -        ui.image{ static = "icons/16/cancel.png" }
    5.14 -        slot.put(_"Cancel password reset")
    5.15 +        slot.put(_"Cancel")
    5.16      end,
    5.17      module = "index",
    5.18 -    view = "index"
    5.19 +    view = "login"
    5.20    }
    5.21  end)
    5.22  
    5.23 @@ -34,10 +33,12 @@
    5.24      },
    5.25      content = function()
    5.26        ui.field.text{ 
    5.27 -        label = "Login",
    5.28 +        label = _"login name",
    5.29          name = "login"
    5.30        }
    5.31        ui.submit{ text = _"Request password reset link" }
    5.32 +      slot.put("&nbsp;&nbsp;")
    5.33 +      ui.link{ module = "index", view = "send_login", text = _"Forgot login name?" }
    5.34      end
    5.35    }
    5.36  
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/app/main/index/send_login.lua	Sat Apr 20 18:51:28 2013 +0200
     6.3 @@ -0,0 +1,35 @@
     6.4 +ui.title(_"Request email with login name")
     6.5 +
     6.6 +ui.actions(function()
     6.7 +  ui.link{
     6.8 +    content = function()
     6.9 +        slot.put(_"Cancel")
    6.10 +    end,
    6.11 +    module = "index",
    6.12 +    view = "login"
    6.13 +  }
    6.14 +end)
    6.15 +
    6.16 +ui.tag{
    6.17 +  tag = 'p',
    6.18 +  content = _'Please enter your email address. You will receive an email with your login name.'
    6.19 +}
    6.20 +ui.form{
    6.21 +  attr = { class = "vertical" },
    6.22 +  module = "index",
    6.23 +  action = "send_login",
    6.24 +  routing = {
    6.25 +    ok = {
    6.26 +      mode = "redirect",
    6.27 +      module = "index",
    6.28 +      view = "index"
    6.29 +    }
    6.30 +  },
    6.31 +  content = function()
    6.32 +    ui.field.text{ 
    6.33 +      label = _"Email address",
    6.34 +      name = "email"
    6.35 +    }
    6.36 +    ui.submit{ text = _"Request email with login name" }
    6.37 +  end
    6.38 +}

Impressum / About Us