mod_invites, mod_easy_invite: Add support for password reset invites (requires Prosody 99ae457c2459)
This commit is contained in:
parent
b2d3caede6
commit
395ab8d404
|
@ -143,6 +143,9 @@ module:hook("user-registering", function (event)
|
|||
event.reason = "Registration on this server is through invitation only";
|
||||
return;
|
||||
end
|
||||
if validated_invite.additional_data and validated_invite.additional_data.allow_reset then
|
||||
event.allow_reset = validated_invite.additional_data.allow_reset;
|
||||
end
|
||||
end);
|
||||
|
||||
-- Make a *one-way* subscription. User will see when contact is online,
|
||||
|
@ -203,19 +206,30 @@ function module.command(arg)
|
|||
assert(hosts[host], "Host "..tostring(host).." does not exist");
|
||||
sm.initialize_host(host);
|
||||
|
||||
-- Load mod_invites
|
||||
invites = module:context(host):depends("invites");
|
||||
module:context(host):depends("invites_page");
|
||||
|
||||
table.remove(arg, 1);
|
||||
table.remove(arg, 1);
|
||||
|
||||
local roles;
|
||||
local invite, roles;
|
||||
if arg[1] == "--reset" then
|
||||
local nodeprep = require "util.encodings".stringprep.nodeprep;
|
||||
local username = nodeprep(arg[2]);
|
||||
if not username then
|
||||
print("Please supply a valid username to generate a reset link for");
|
||||
return;
|
||||
end
|
||||
invite = invites.create_account_reset(username);
|
||||
else
|
||||
if arg[1] == "--admin" then
|
||||
roles = { ["prosody:admin"] = true };
|
||||
elseif arg[1] == "--role" then
|
||||
roles = { [arg[2]] = true };
|
||||
end
|
||||
|
||||
invites = module:context(host):depends("invites");
|
||||
module:context(host):depends("invites_page");
|
||||
local invite = invites.create_account(nil, { roles = roles });
|
||||
print(invite.landing_page or invite.uri);
|
||||
invite = invites.create_account(nil, { roles = roles });
|
||||
end
|
||||
|
||||
print(invite.landing_page or invite.uri);
|
||||
end
|
||||
|
|
|
@ -64,11 +64,17 @@ function create_account(account_username, additional_data) --luacheck: ignore 13
|
|||
return create_invite("register", jid, true, additional_data);
|
||||
end
|
||||
|
||||
-- Create invitation to reset the password for an account
|
||||
function create_account_reset(account_username) --luacheck: ignore 131/create_account_reset
|
||||
return create_account(account_username, { allow_reset = account_username });
|
||||
end
|
||||
|
||||
-- Create invitation to become a contact of a local user
|
||||
function create_contact(username, allow_registration, additional_data) --luacheck: ignore 131/create_contact
|
||||
return create_invite("roster", username.."@"..module.host, allow_registration, additional_data);
|
||||
end
|
||||
|
||||
|
||||
local valid_invite_methods = {};
|
||||
local valid_invite_mt = { __index = valid_invite_methods };
|
||||
|
||||
|
|
Loading…
Reference in New Issue