Mercurial > prosody-modules
comparison mod_invites_register_api/mod_invites_register_api.lua @ 4414:dbfa830e4504
mod_invites_register_api: Handle password resets
Those need the information for whom they are in the GET response
as well as special handling in the POST.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Sat, 30 Jan 2021 10:47:57 +0100 |
parents | a1256e376dca |
children |
comparison
equal
deleted
inserted
replaced
4413:0b9501f82e63 | 4414:dbfa830e4504 |
---|---|
27 domain = module.host; | 27 domain = module.host; |
28 uri = invite.uri; | 28 uri = invite.uri; |
29 type = invite.type; | 29 type = invite.type; |
30 jid = invite.jid; | 30 jid = invite.jid; |
31 inviter = invite.inviter; | 31 inviter = invite.inviter; |
32 reset = invite.additional_data and invite.additional_data.allow_reset or nil; | |
32 }); | 33 }); |
33 end | 34 end |
34 | 35 |
35 function register_with_invite(event) | 36 function register_with_invite(event) |
36 local request, response = event.request, event.response; | 37 local request, response = event.request, event.response; |
66 | 67 |
67 if not prepped_username or #prepped_username == 0 then | 68 if not prepped_username or #prepped_username == 0 then |
68 return 400; | 69 return 400; |
69 end | 70 end |
70 | 71 |
71 if usermanager.user_exists(prepped_username, module.host) then | 72 local reset_for = invite.additional_data and invite.additional_data.allow_reset or nil; |
73 if reset_for ~= nil then | |
74 module:log("debug", "handling password reset invite for %s", reset_for) | |
75 if reset_for ~= prepped_username then | |
76 return 403; -- Attempt to use reset invite for incorrect user | |
77 end | |
78 elseif usermanager.user_exists(prepped_username, module.host) then | |
72 return 409; -- Conflict | 79 return 409; -- Conflict |
73 end | 80 end |
74 | 81 |
75 local registering = { | 82 local registering = { |
76 validated_invite = invite; | 83 validated_invite = invite; |