Mercurial > prosody-modules
diff mod_easy_invite/mod_easy_invite.lua @ 4023:7e2db4d61f6c
mod_easy_invite: backport: ensure session exists before accessing it
Backport from https://github.com/snikket-im/snikket-server
This prevents a 500 issue when using mod_register_web.
author | Maxime “pep” Buquet <pep@bouah.net> |
---|---|
date | Sun, 17 May 2020 22:38:55 +0200 |
parents | 3ac31ddab7eb |
children | 6cdbca89b8be |
line wrap: on
line diff
--- a/mod_easy_invite/mod_easy_invite.lua Sat May 16 19:48:26 2020 +0200 +++ b/mod_easy_invite/mod_easy_invite.lua Sun May 17 22:38:55 2020 +0200 @@ -137,7 +137,7 @@ -- Registration attempt - ensure a valid preauth token has been supplied module:hook("user-registering", function (event) - local validated_invite = event.session.validated_invite; + local validated_invite = event.validated_invite or (event.session and event.session.validated_invite); if invite_only and not validated_invite then event.allowed = false; event.reason = "Registration on this server is through invitation only"; @@ -169,7 +169,7 @@ -- Registration successful, if there was a preauth token, mark it as used module:hook("user-registered", function (event) - local validated_invite = event.session.validated_invite; + local validated_invite = event.validated_invite or (event.session and event.session.validated_invite); if not validated_invite then return; end