liquid_feedback_frontend

view 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 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")
20 ui.form{
21 attr = { class = "section vertical" },
22 module = 'index',
23 action = 'register',
24 params = {
25 code = code,
26 notify_email = notify_email,
27 name = name,
28 login = login
29 },
30 content = function()
32 if not code and not ldap_uid then
33 ui.field.hidden{ name = "step", value = 1 }
34 ui.title(_"Registration (step 1 of 3: Invite code)")
35 ui.sectionHead( function()
36 ui.heading { level = 1, content = _"Please enter the invite code you've received" }
37 end )
38 ui.sectionRow( function()
39 ui.field.text{
40 label = _'Invite code',
41 name = 'code',
42 value = param.get("invite")
43 }
44 ui.submit{
45 text = _'proceed with registration'
46 }
47 slot.put(" ")
48 ui.link{
49 content = _"cancel registration",
50 module = "index",
51 action = "cancel_register",
52 routing = { default = {
53 mode = "redirect", module = "index", view = "index"
54 } }
55 }
56 end )
57 else
58 local member
60 if ldap_uid then
61 member, err = ldap.create_member(ldap_uid, true)
62 if err then
63 error(err)
64 end
65 else
66 member = Member:new_selector()
67 :add_where{ "invite_code = ?", code }
68 :add_where{ "activated ISNULL" }
69 :optional_object_mode()
70 :exec()
71 end
73 if (not member.notify_email and not notify_email)
74 or (not member.name and not name)
75 or (not member.login and not login and not member.authority)
76 or step == 1 then
77 ui.title(_"Registration (step 2 of 3: Personal information)")
78 ui.field.hidden{ name = "step", value = 2 }
80 ui.sectionHead( function()
81 ui.heading { level = 1, content = _"Check and enter personal data" }
82 end )
83 ui.sectionRow( function()
84 ui.tag{
85 tag = "p",
86 content = _"This invite key is connected with the following information:"
87 }
89 execute.view{ module = "member", view = "_profile", params = { member = member, for_registration = true } }
91 if not util.is_profile_field_locked(member, "notify_email") then
92 ui.tag{
93 tag = "p",
94 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."
95 }
96 ui.field.text{
97 label = _'Email address',
98 name = 'notify_email',
99 value = param.get("notify_email") or member.notify_email
100 }
101 end
102 if not util.is_profile_field_locked(member, "name") then
103 ui.tag{
104 tag = "p",
105 content = _"Please choose a name, i.e. your real name or your nick name. This name will be shown to others to identify you."
106 }
107 ui.field.text{
108 label = _'Screen name',
109 name = 'name',
110 value = param.get("name") or member.name
111 }
112 end
113 if not util.is_profile_field_locked(member, "login") then
114 ui.tag{
115 tag = "p",
116 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."
117 }
118 ui.field.text{
119 label = _'Login name',
120 name = 'login',
121 value = param.get("login") or member.login
122 }
123 end
124 ui.submit{
125 text = _'proceed with registration'
126 }
127 slot.put(" ")
128 ui.link{
129 content = _"one step back",
130 module = "index",
131 view = "register",
132 params = {
133 invite = code
134 }
135 }
136 slot.put(" ")
137 ui.link{
138 content = _"cancel registration",
139 module = "index",
140 action = "cancel_register",
141 routing = { default = {
142 mode = "redirect", module = "index", view = "index"
143 } }
144 }
145 end )
146 else
148 ui.field.hidden{ name = "step", value = "3" }
149 ui.title(_"Registration (step 3 of 3: Terms of use and password)")
150 ui.sectionHead( function()
151 ui.heading { level = 1, content = _"Read and accept the terms and choose a password" }
152 end )
153 ui.sectionRow( function()
154 ui.container{
155 attr = { class = "wiki use_terms" },
156 content = function()
157 slot.put(config.use_terms)
158 end
159 }
161 member.notify_email = notify_email or member.notify_email
162 member.name = name or member.name
163 member.login = login or member.login
165 execute.view{ module = "member", view = "_profile", params = {
166 member = member, include_private_data = true
167 } }
169 for i, checkbox in ipairs(config.use_terms_checkboxes) do
170 slot.put("<br />")
171 ui.tag{
172 tag = "div",
173 content = function()
174 ui.tag{
175 tag = "input",
176 attr = {
177 type = "checkbox",
178 id = "use_terms_checkbox_" .. checkbox.name,
179 name = "use_terms_checkbox_" .. checkbox.name,
180 value = "1",
181 style = "float: left;",
182 checked = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) and "checked" or nil
183 }
184 }
185 slot.put("&nbsp;")
186 ui.tag{
187 tag = "label",
188 attr = { ['for'] = "use_terms_checkbox_" .. checkbox.name },
189 content = function() slot.put(checkbox.html) end
190 }
191 end
192 }
193 end
195 slot.put("<br />")
197 if not member.authority == "ldap" then
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.text{
203 readonly = true,
204 label = _'Login name',
205 name = 'login',
206 value = member.login
207 }
208 ui.field.password{
209 label = _'Password',
210 name = 'password1',
211 }
212 ui.field.password{
213 label = _'Password (repeat)',
214 name = 'password2',
215 }
216 end
218 ui.submit{
219 text = _'activate account'
220 }
221 slot.put(" ")
222 ui.link{
223 content = _"one step back",
224 module = "index",
225 view = "register",
226 params = {
227 code = code,
228 notify_email = notify_email,
229 name = name,
230 login = login,
231 step = 1
232 }
233 }
234 slot.put(" ")
235 ui.link{
236 content = _"cancel registration",
237 module = "index",
238 action = "cancel_register",
239 routing = { default = {
240 mode = "redirect", module = "index", view = "index"
241 } }
242 }
243 end )
244 end
245 end
246 end
247 }

Impressum / About Us