liquid_feedback_frontend

view app/main/index/_action/login.lua @ 756:c2022db9f64c

Text updated
author bsw
date Thu Jun 28 22:49:57 2012 +0200 (2012-06-28)
parents 93a40d1c66f4
children e3887fea39fa
line source
1 local member = Member:by_login_and_password(param.get('login'), param.get('password'))
3 function do_etherpad_auth(member)
4 local result = net.curl(
5 config.etherpad.api_base
6 .. "api/1/createAuthorIfNotExistsFor?apikey=" .. config.etherpad.api_key
7 .. "&name=" .. encode.url_part(member.name) .. "&authorMapper=" .. tostring(member.id)
8 )
10 if not result then
11 slot.put_into("error", _"Etherpad authentication failed" .. " 1")
12 return false
13 end
15 local etherpad_author_id = string.match(result, '"authorID"%s*:%s*"([^"]+)"')
17 if not etherpad_author_id then
18 slot.put_into("error", _"Etherpad authentication failed" .. " 2")
19 return false
20 end
22 local time_in_24h = os.time() + 24 * 60 * 60
24 local result = net.curl(
25 config.etherpad.api_base
26 .. "api/1/createSession?apikey=" .. config.etherpad.api_key
27 .. "&groupID=" .. config.etherpad.group_id
28 .. "&authorID=" .. etherpad_author_id
29 .. "&validUntil=" .. time_in_24h
30 )
32 if not result then
33 slot.put_into("error", _"Etherpad authentication failed" .. " 3")
34 return false
35 end
37 local etherpad_sesion_id = string.match(result, '"sessionID"%s*:%s*"([^"]+)"')
39 if not etherpad_sesion_id then
40 slot.put_into("error", _"Etherpad authentication failed" .. " 4")
41 return false
42 end
44 request.set_cookie{
45 path = config.etherpad.cookie_path,
46 name = "sessionID",
47 value = etherpad_sesion_id
48 }
50 end
53 if member then
54 member.last_login = "now"
55 member.last_activity = "now"
56 member.active = true
57 if member.lang == nil then
58 member.lang = app.session.lang
59 else
60 app.session.lang = member.lang
61 end
62 member:save()
63 app.session.member = member
64 app.session:save()
65 trace.debug('User authenticated')
66 if config.etherpad then
67 do_etherpad_auth(member)
68 end
69 else
70 slot.select("error", function()
71 ui.tag{ content = _'Invalid login name or password!' }
72 end)
73 trace.debug('User NOT authenticated')
74 return false
75 end

Impressum / About Us