liquid_feedback_frontend

view app/main/index/register.lua @ 1858:3d1f0464a3ea

Handle missing ldap.member.allowed function
author bsw
date Tue Sep 20 17:35:29 2022 +0200 (20 months ago)
parents 32cc544d5a5b
children
line source
1 local ldap_uid
3 if config.ldap.member and app.session.authority == "ldap" then
4 ldap_uid = app.session.authority_uid
5 end
7 if config.registration_disabled and not ldap_uid then
8 return execute.view { module = "index", view = "404" }
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.container{ attr = { class = "mdl-grid" }, content = function()
37 ui.container{ attr = { class = "mdl-cell mdl-cell--12-col" }, content = function()
38 ui.heading{ level = 1, content = _"Account registration" }
39 --[[
40 if not code and not ldap_uid then
41 ui.heading{ level = 1, content = _"Registration (step 1 of 3: Invite code)" }
42 elseif (not member.notify_email and not notify_email)
43 or (not member.name and not name)
44 or (not member.login and not login and not member.authority)
45 or step == 1 then
46 ui.heading { level = 1, content = _"Registration (step 2 of 3: Personal information)" }
47 else
48 ui.heading { level = 1, content = _"Registration (step 3 of 3: Terms of use and password)" }
49 end
50 --]]
51 ui.sectionRow( function()
52 ui.form{
53 attr = { class = "wide" },
54 module = 'index',
55 action = 'register',
56 params = {
57 code = code,
58 notify_email = notify_email,
59 name = name,
60 login = login,
61 skip = param.get("skip"),
62 redirect_module = param.get("redirect_module"),
63 redirect_view = param.get("redirect_view"),
64 redirect_id = param.get("redirect_id"),
65 redirect_params = param.get("redirect_params")
66 },
67 content = function()
69 if not code and not ldap_uid then
70 ui.field.hidden{ name = "step", value = 1 }
71 ui.tag { tag = "p", content = _"Please enter the invite code you've received" }
72 ui.field.text{
73 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
74 attr = { id = "lf-register__code", class = "mdl-textfield__input" },
75 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
76 label = _'Invite code',
77 name = 'code',
78 value = ''
79 }
80 slot.put("<br /><br />")
81 ui.tag{
82 tag = "input",
83 attr = {
84 type = "submit",
85 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
86 value = _'proceed with registration'
87 }
88 }
89 slot.put(" ")
90 else
91 if (not member.notify_email and not notify_email)
92 or (not member.name and not name)
93 or (not member.login and not login and not member.authority)
94 or step == 1 then
95 ui.field.hidden{ name = "step", value = 2 }
97 ui.tag{
98 tag = "p",
99 content = _"This invite key is connected with the following information:"
100 }
102 execute.view{ module = "member", view = "_profile", params = { member = member, for_registration = true } }
104 slot.put("<br /><br />")
106 if not util.is_profile_field_locked(member, "notify_email") and not member.notify_email then
107 ui.tag{
108 tag = "p",
109 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."
110 }
111 ui.field.text{
112 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
113 attr = { id = "lf-register__code", class = "mdl-textfield__input" },
114 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
115 label = _'Email address',
116 name = 'notify_email',
117 value = param.get("notify_email") or member.notify_email
118 }
119 end
120 if not util.is_profile_field_locked(member, "name") then
121 ui.tag{
122 tag = "p",
123 content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
124 }
125 ui.field.text{
126 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
127 attr = { id = "lf-register__code", class = "mdl-textfield__input" },
128 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
129 label = _'Screen name',
130 name = 'name',
131 value = param.get("name") or member.name
132 }
133 end
134 if not util.is_profile_field_locked(member, "login") then
135 ui.tag{
136 tag = "p",
137 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."
138 }
139 ui.field.text{
140 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
141 attr = { id = "lf-register__code", class = "mdl-textfield__input" },
142 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
143 label = _'Login name',
144 name = 'login',
145 value = param.get("login") or member.login
146 }
147 end
148 slot.put("<br /><br />")
149 ui.tag{
150 tag = "input",
151 attr = {
152 type = "submit",
153 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
154 value = _'proceed with registration'
155 }
156 }
157 if param.get("skip") ~= "1" then
158 slot.put(" ")
159 ui.link{
160 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
161 content = _"one step back",
162 module = "index",
163 view = "register",
164 params = {
165 invite = code,
166 redirect_module = param.get("redirect_module"),
167 redirect_view = param.get("redirect_view"),
168 redirect_id = param.get("redirect_id"),
169 redirect_params = param.get("redirect_params")
170 }
171 }
172 end
173 else
174 ui.field.hidden{ name = "step", value = "3" }
176 local need_to_accept_terms = false
178 for i, checkbox in ipairs(config.use_terms_checkboxes) do
179 local member_useterms = MemberUseterms:new_selector()
180 :add_where{ "member_id = ?", member.id }
181 :add_where{ "contract_identifier = ?", checkbox.name }
182 :exec()
183 if #member_useterms == 0 then
184 need_to_accept_terms = true
185 end
186 end
188 if need_to_accept_terms then
189 ui.container{
190 attr = { class = "wiki use_terms" },
191 content = function()
192 slot.put(config.use_terms)
193 end
194 }
196 for i, checkbox in ipairs(config.use_terms_checkboxes) do
197 local member_useterms = MemberUseterms:new_selector()
198 :add_where{ "member_id = ?", member.id }
199 :add_where{ "contract_identifier = ?", checkbox.name }
200 :exec()
201 if #member_useterms == 0 then
202 slot.put("<br />")
203 ui.tag{
204 tag = "div",
205 content = function()
206 ui.tag{
207 tag = "input",
208 attr = {
209 type = "checkbox",
210 id = "use_terms_checkbox_" .. checkbox.name,
211 name = "use_terms_checkbox_" .. checkbox.name,
212 value = "1",
213 style = "float: left;",
214 checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
215 }
216 }
217 slot.put("&nbsp;")
218 ui.tag{
219 tag = "label",
220 attr = { ['for'] = "use_terms_checkbox_" .. checkbox.name },
221 content = function() slot.put(checkbox.html) end
222 }
223 end
224 }
225 end
226 end
228 slot.put("<br />")
229 end
231 member.notify_email = notify_email or member.notify_email
232 member.name = name or member.name
233 member.login = login or member.login
235 -- ui.heading { level = 2, content = _"Personal information" }
236 -- execute.view{ module = "member", view = "_profile", params = {
237 -- member = member, include_private_data = true
238 -- } }
239 -- ui.field.text{
240 -- readonly = true,
241 -- label = _'Login name',
242 -- name = 'login',
243 -- value = member.login
244 -- }
246 if not (member.authority == "ldap") then
247 ui.tag{
248 tag = "p",
249 content = _"Please choose a password and enter it twice. The password is case sensitive."
250 }
251 ui.field.password{
252 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
253 attr = { id = "lf-register__code", class = "mdl-textfield__input" },
254 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
255 label = _'Password',
256 name = 'password1',
257 }
258 slot.put("<br />")
259 ui.field.password{
260 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" },
261 attr = { id = "lf-register__code", class = "mdl-textfield__input" },
262 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__code" },
263 label = _'Repeat password',
264 name = 'password2',
265 }
266 end
268 slot.put("<br /><br />")
269 ui.tag{
270 tag = "input",
271 attr = {
272 type = "submit",
273 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
274 value = _'activate account'
275 }
276 }
277 slot.put(" ")
278 ui.link{
279 attr = { class = "mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--underlined" },
280 content = _"one step back",
281 module = "index",
282 view = "register",
283 params = {
284 code = code,
285 notify_email = notify_email,
286 name = name,
287 login = login,
288 skip = param.get("skip"),
289 step = 1,
290 redirect_module = param.get("redirect_module"),
291 redirect_view = param.get("redirect_view"),
292 redirect_id = param.get("redirect_id"),
293 redirect_params = param.get("redirect_params")
294 }
295 }
296 end
297 end
298 end
299 }
301 slot.put("<br /><br />")
303 ui.link{
304 attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" },
305 content = _"cancel",
306 module = "index",
307 action = "cancel_register",
308 routing = { default = {
309 mode = "redirect", module = "index", view = "login", params = {
310 redirect_module = param.get("redirect_module"),
311 redirect_view = param.get("redirect_view"),
312 redirect_id = param.get("redirect_id"),
313 redirect_params = param.get("redirect_params")
314 }
315 } }
316 }
317 end )
318 end }
319 end }

Impressum / About Us