plugins/mod_legacyauth.lua

changeset 1830
5408d5100bd0
parent 1829
a805e4fe104a
child 1833
f4c88dd32724
equal deleted inserted replaced
1829:a805e4fe104a 1830:5408d5100bd0
50 username, password, resource = t_concat(username), t_concat(password), t_concat(resource); 50 username, password, resource = t_concat(username), t_concat(password), t_concat(resource);
51 username = nodeprep(username); 51 username = nodeprep(username);
52 resource = resourceprep(resource) 52 resource = resourceprep(resource)
53 local reply = st.reply(stanza); 53 local reply = st.reply(stanza);
54 require "core.usermanager" 54 require "core.usermanager"
55 if username and usermanager.validate_credentials(session.host, username, password) then 55 if username and resource and usermanager.validate_credentials(session.host, username, password) then
56 -- Authentication successful! 56 -- Authentication successful!
57 local success, err = sessionmanager.make_authenticated(session, username); 57 local success, err = sessionmanager.make_authenticated(session, username);
58 if success then 58 if success then
59 local err_type, err_msg; 59 local err_type, err_msg;
60 success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource); 60 success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource);
61 if not success then 61 if not success then
62 session.send(st.error_reply(stanza, err_type, err, err_msg)); 62 session.send(st.error_reply(stanza, err_type, err, err_msg));
63 session.username, session.type = nil, "c2s_unauthed"; -- FIXME should this be placed in sessionmanager? 63 session.username, session.type = nil, "c2s_unauthed"; -- FIXME should this be placed in sessionmanager?
64 return true;
65 elseif resource ~= session.resource then -- server changed resource, not supported by legacy auth
66 session.send(st.error_reply(stanza, "cancel", "conflict", "The requested resource could not be assigned to this session."));
67 session:close(); -- FIXME undo resource bind and auth instead of closing the session?
64 return true; 68 return true;
65 end 69 end
66 end 70 end
67 session.send(st.reply(stanza)); 71 session.send(st.reply(stanza));
68 return true; 72 return true;

mercurial