liquid_feedback_frontend

diff app/main/index/register.lua @ 1071:58f48a8a202a

Imported and merged LDAP patch
author bsw
date Fri Jul 18 21:42:59 2014 +0200 (2014-07-18)
parents 701a5cf6b067
children f9c1acb859d0
line diff
     1.1 --- a/app/main/index/register.lua	Thu Jul 17 23:38:35 2014 +0200
     1.2 +++ b/app/main/index/register.lua	Fri Jul 18 21:42:59 2014 +0200
     1.3 @@ -1,3 +1,13 @@
     1.4 +local ldap_uid
     1.5 +
     1.6 +if config.ldap.member and app.session.authority == "ldap" then
     1.7 +  ldap_uid = app.session.authority_data_uid
     1.8 +end
     1.9 +
    1.10 +if config.registration_disabled and not ldap_uid then
    1.11 +  error("registration disabled")
    1.12 +end
    1.13 +
    1.14  execute.view{ module = "index", view = "_lang_chooser" }
    1.15  
    1.16  local step = param.get("step", atom.integer)
    1.17 @@ -6,6 +16,7 @@
    1.18  local name = param.get("name")
    1.19  local login = param.get("login")
    1.20  
    1.21 +
    1.22  ui.form{
    1.23    attr = { class = "section vertical" },
    1.24    module = 'index',
    1.25 @@ -18,7 +29,7 @@
    1.26    },
    1.27    content = function()
    1.28  
    1.29 -    if not code then
    1.30 +    if not code and not ldap_uid then
    1.31        ui.field.hidden{ name = "step", value = 1 }
    1.32        ui.title(_"Registration (step 1 of 3: Invite code)")
    1.33        ui.sectionHead( function()
    1.34 @@ -37,17 +48,32 @@
    1.35          ui.link{
    1.36            content = _"cancel registration",
    1.37            module = "index",
    1.38 -          view = "index"
    1.39 +          action = "cancel_register",
    1.40 +          routing = { default = {
    1.41 +            mode = "redirect", module = "index", view = "index"
    1.42 +          } }
    1.43          }
    1.44        end )
    1.45      else
    1.46 -      local member = Member:new_selector()
    1.47 -        :add_where{ "invite_code = ?", code }
    1.48 -        :add_where{ "activated ISNULL" }
    1.49 -        :optional_object_mode()
    1.50 -        :exec()
    1.51 +      local member
    1.52 +      
    1.53 +      if ldap_uid then
    1.54 +        member, err = ldap.create_member(ldap_uid, true)
    1.55 +        if err then
    1.56 +          error(err)
    1.57 +        end
    1.58 +      else
    1.59 +        member = Member:new_selector()
    1.60 +          :add_where{ "invite_code = ?", code }
    1.61 +          :add_where{ "activated ISNULL" }
    1.62 +          :optional_object_mode()
    1.63 +          :exec()
    1.64 +      end
    1.65  
    1.66 -      if not member.notify_email and not notify_email or not member.name and not name or not member.login and not login or step == 1 then
    1.67 +      if    (not member.notify_email and not notify_email)
    1.68 +         or (not member.name and not name)
    1.69 +         or (not member.login and not login and not member.authority)
    1.70 +         or step == 1 then
    1.71          ui.title(_"Registration (step 2 of 3: Personal information)")
    1.72          ui.field.hidden{ name = "step", value = 2 }
    1.73  
    1.74 @@ -62,7 +88,7 @@
    1.75            
    1.76            execute.view{ module = "member", view = "_profile", params = { member = member, for_registration = true } }
    1.77  
    1.78 -          if not config.locked_profile_fields.notify_email then
    1.79 +          if not util.is_profile_field_locked(member, "notify_email") then
    1.80              ui.tag{
    1.81                tag = "p",
    1.82                content = _"Please enter your email address. This address will be used for automatic notifications (if you request them) and in case you've lost your password. This address will not be published. After registration you will receive an email with a confirmation link."
    1.83 @@ -73,7 +99,7 @@
    1.84                value     = param.get("notify_email") or member.notify_email
    1.85              }
    1.86            end
    1.87 -          if not config.locked_profile_fields.name then
    1.88 +          if not util.is_profile_field_locked(member, "name") then
    1.89              ui.tag{
    1.90                tag = "p",
    1.91                content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
    1.92 @@ -84,7 +110,7 @@
    1.93                value     = param.get("name") or member.name
    1.94              }
    1.95            end
    1.96 -          if not config.locked_profile_fields.login then
    1.97 +          if not util.is_profile_field_locked(member, "login") then
    1.98              ui.tag{
    1.99                tag = "p",
   1.100                content = _"Please choose a login name. This name will not be shown to others and is used only by you to login into the system. The login name is case sensitive."
   1.101 @@ -111,7 +137,10 @@
   1.102            ui.link{
   1.103              content = _"cancel registration",
   1.104              module = "index",
   1.105 -            view = "index"
   1.106 +            action = "cancel_register",
   1.107 +            routing = { default = {
   1.108 +              mode = "redirect", module = "index", view = "index"
   1.109 +            } }
   1.110            }
   1.111          end )
   1.112        else
   1.113 @@ -165,24 +194,27 @@
   1.114  
   1.115            slot.put("<br />")
   1.116  
   1.117 -          ui.tag{
   1.118 -            tag = "p",
   1.119 -            content = _"Please choose a password and enter it twice. The password is case sensitive."
   1.120 -          }
   1.121 -          ui.field.text{
   1.122 -            readonly  = true,
   1.123 -            label     = _'Login name',
   1.124 -            name      = 'login',
   1.125 -            value     = member.login
   1.126 -          }
   1.127 -          ui.field.password{
   1.128 -            label     = _'Password',
   1.129 -            name      = 'password1',
   1.130 -          }
   1.131 -          ui.field.password{
   1.132 -            label     = _'Password (repeat)',
   1.133 -            name      = 'password2',
   1.134 -          }
   1.135 +          if not member.authority == "ldap" then
   1.136 +            ui.tag{
   1.137 +              tag = "p",
   1.138 +              content = _"Please choose a password and enter it twice. The password is case sensitive."
   1.139 +            }
   1.140 +            ui.field.text{
   1.141 +              readonly  = true,
   1.142 +              label     = _'Login name',
   1.143 +              name      = 'login',
   1.144 +              value     = member.login
   1.145 +            }
   1.146 +            ui.field.password{
   1.147 +              label     = _'Password',
   1.148 +              name      = 'password1',
   1.149 +            }
   1.150 +            ui.field.password{
   1.151 +              label     = _'Password (repeat)',
   1.152 +              name      = 'password2',
   1.153 +            }
   1.154 +          end
   1.155 +          
   1.156            ui.submit{
   1.157              text = _'activate account'
   1.158            }
   1.159 @@ -203,7 +235,10 @@
   1.160            ui.link{
   1.161              content = _"cancel registration",
   1.162              module = "index",
   1.163 -            view = "index"
   1.164 +            action = "cancel_register",
   1.165 +            routing = { default = {
   1.166 +              mode = "redirect", module = "index", view = "index"
   1.167 +            } }
   1.168            }
   1.169          end )
   1.170        end

Impressum / About Us