33 if query.tags[1] and query.tags[1].name == "remove" then |
33 if query.tags[1] and query.tags[1].name == "remove" then |
34 -- TODO delete user auth data, send iq response, kick all user resources with a <not-authorized/>, delete all user data |
34 -- TODO delete user auth data, send iq response, kick all user resources with a <not-authorized/>, delete all user data |
35 local username, host = session.username, session.host; |
35 local username, host = session.username, session.host; |
36 --session.send(st.error_reply(stanza, "cancel", "not-allowed")); |
36 --session.send(st.error_reply(stanza, "cancel", "not-allowed")); |
37 --return; |
37 --return; |
38 usermanager_set_password(username, host, nil); -- Disable account |
38 usermanager_set_password(username, nil, host); -- Disable account |
39 -- FIXME the disabling currently allows a different user to recreate the account |
39 -- FIXME the disabling currently allows a different user to recreate the account |
40 -- we should add an in-memory account block mode when we have threading |
40 -- we should add an in-memory account block mode when we have threading |
41 session.send(st.reply(stanza)); |
41 session.send(st.reply(stanza)); |
42 local roster = session.roster; |
42 local roster = session.roster; |
43 for _, session in pairs(hosts[host].sessions[username].sessions) do -- disconnect all resources |
43 for _, session in pairs(hosts[host].sessions[username].sessions) do -- disconnect all resources |
68 if username and password then |
68 if username and password then |
69 -- FIXME shouldn't use table.concat |
69 -- FIXME shouldn't use table.concat |
70 username = nodeprep(table.concat(username)); |
70 username = nodeprep(table.concat(username)); |
71 password = table.concat(password); |
71 password = table.concat(password); |
72 if username == session.username then |
72 if username == session.username then |
73 if usermanager_set_password(username, session.host, password) then |
73 if usermanager_set_password(username, password, session.host) then |
74 session.send(st.reply(stanza)); |
74 session.send(st.reply(stanza)); |
75 else |
75 else |
76 -- TODO unable to write file, file may be locked, etc, what's the correct error? |
76 -- TODO unable to write file, file may be locked, etc, what's the correct error? |
77 session.send(st.error_reply(stanza, "wait", "internal-server-error")); |
77 session.send(st.error_reply(stanza, "wait", "internal-server-error")); |
78 end |
78 end |