liquid_feedback_frontend

view app/main/index/register.lua @ 1073:f9c1acb859d0

Fixed errors in registration after import of LDAP patch, updated registration layout
author bsw
date Fri Jul 18 23:13:19 2014 +0200 (2014-07-18)
parents 58f48a8a202a
children aefef1556d55
line source
1 local ldap_uid
3 if config.ldap.member and app.session.authority == "ldap" then
4 ldap_uid = app.session.authority_data_uid
5 end
7 if config.registration_disabled and not ldap_uid then
8 error("registration disabled")
9 end
11 execute.view{ module = "index", view = "_lang_chooser" }
13 local step = param.get("step", atom.integer)
14 local code = param.get("code")
15 local notify_email = param.get("notify_email")
16 local name = param.get("name")
17 local login = param.get("login")
19 local member
21 if ldap_uid then
22 member, err = ldap.create_member(ldap_uid, true)
23 if err then
24 error(err)
25 end
26 elseif code then
27 member = Member:new_selector()
28 :add_where{ "invite_code = ?", code }
29 :add_where{ "activated ISNULL" }
30 :optional_object_mode()
31 :exec()
32 end
36 ui.section( function()
38 if not code and not ldap_uid then
39 ui.title(_"Registration (step 1 of 3: Invite code)")
40 ui.sectionHead( function()
41 ui.heading { level = 1, content = _"Invite code" }
42 end )
43 elseif (not member.notify_email and not notify_email)
44 or (not member.name and not name)
45 or (not member.login and not login and not member.authority)
46 or step == 1 then
47 ui.title(_"Registration (step 2 of 3: Personal information)")
48 ui.sectionHead( function()
49 ui.heading { level = 1, content = _"Check and enter personal data" }
50 end )
51 else
52 ui.title(_"Registration (step 3 of 3: Terms of use and password)")
53 ui.sectionHead( function()
54 ui.heading { level = 1, content = _"Read and accept the terms and choose a password" }
55 end )
56 end
58 ui.sectionRow( function()
59 ui.form{
60 attr = { class = "wide" },
61 module = 'index',
62 action = 'register',
63 params = {
64 code = code,
65 notify_email = notify_email,
66 name = name,
67 login = login
68 },
69 content = function()
71 if not code and not ldap_uid then
72 ui.field.hidden{ name = "step", value = 1 }
73 ui.heading { level = 2, content = _"Please enter the invite code you've received" }
74 ui.field.text{
75 name = 'code',
76 value = param.get("invite")
77 }
78 ui.submit{
79 text = _'proceed with registration',
80 attr = { class = "btn btn-default" }
81 }
82 slot.put(" ")
83 else
84 if (not member.notify_email and not notify_email)
85 or (not member.name and not name)
86 or (not member.login and not login and not member.authority)
87 or step == 1 then
88 ui.field.hidden{ name = "step", value = 2 }
90 ui.tag{
91 tag = "p",
92 content = _"This invite key is connected with the following information:"
93 }
95 execute.view{ module = "member", view = "_profile", params = { member = member, for_registration = true } }
97 if not util.is_profile_field_locked(member, "notify_email") then
98 ui.heading { level = 2, content = _'Email address' }
99 ui.tag{
100 tag = "p",
101 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."
102 }
103 ui.field.text{
104 name = 'notify_email',
105 value = param.get("notify_email") or member.notify_email
106 }
107 end
108 if not util.is_profile_field_locked(member, "name") then
109 ui.heading { level = 2, content = _'Screen name' }
110 ui.tag{
111 tag = "p",
112 content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
113 }
114 ui.field.text{
115 name = 'name',
116 value = param.get("name") or member.name
117 }
118 end
119 if not util.is_profile_field_locked(member, "login") then
120 ui.heading { level = 2, content = _'Login name' }
121 ui.tag{
122 tag = "p",
123 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."
124 }
125 ui.field.text{
126 name = 'login',
127 value = param.get("login") or member.login
128 }
129 end
130 ui.submit{
131 text = _'proceed with registration',
132 attr = { class = "btn btn-default" }
133 }
134 slot.put(" ")
135 ui.link{
136 content = _"one step back",
137 module = "index",
138 view = "register",
139 params = {
140 invite = code
141 }
142 }
143 else
145 ui.field.hidden{ name = "step", value = "3" }
146 ui.container{
147 attr = { class = "wiki use_terms" },
148 content = function()
149 slot.put(config.use_terms)
150 end
151 }
153 for i, checkbox in ipairs(config.use_terms_checkboxes) do
154 slot.put("<br />")
155 ui.tag{
156 tag = "div",
157 content = function()
158 ui.tag{
159 tag = "input",
160 attr = {
161 type = "checkbox",
162 id = "use_terms_checkbox_" .. checkbox.name,
163 name = "use_terms_checkbox_" .. checkbox.name,
164 value = "1",
165 style = "float: left;",
166 checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
167 }
168 }
169 slot.put("&nbsp;")
170 ui.tag{
171 tag = "label",
172 attr = { ['for'] = "use_terms_checkbox_" .. checkbox.name },
173 content = function() slot.put(checkbox.html) end
174 }
175 end
176 }
177 end
179 slot.put("<br />")
181 member.notify_email = notify_email or member.notify_email
182 member.name = name or member.name
183 member.login = login or member.login
185 ui.heading { level = 2, content = _"Personal information" }
186 execute.view{ module = "member", view = "_profile", params = {
187 member = member, include_private_data = true
188 } }
189 ui.field.text{
190 readonly = true,
191 label = _'Login name',
192 name = 'login',
193 value = member.login
194 }
196 if not (member.authority == "ldap") then
197 ui.heading { level = 2, content = _'Password' }
198 ui.tag{
199 tag = "p",
200 content = _"Please choose a password and enter it twice. The password is case sensitive."
201 }
202 ui.field.password{
203 name = 'password1',
204 }
205 ui.field.password{
206 name = 'password2',
207 }
208 end
210 ui.submit{
211 text = _'activate account',
212 attr = { class = "btn btn-default" }
213 }
214 slot.put(" ")
215 ui.link{
216 content = _"one step back",
217 module = "index",
218 view = "register",
219 params = {
220 code = code,
221 notify_email = notify_email,
222 name = name,
223 login = login,
224 step = 1
225 }
226 }
227 end
228 end
229 end
230 }
232 slot.put("<br /><br />")
234 ui.link{
235 content = _"cancel registration",
236 module = "index",
237 action = "cancel_register",
238 routing = { default = {
239 mode = "redirect", module = "index", view = "index"
240 } }
241 }
242 end )
243 end )

Impressum / About Us