Mercurial > prosody-modules
annotate mod_invites_groups/mod_invites_groups.lua @ 5264:d3ebaef1ea7a
mod_http_oauth2: Correctly verify OAuth client credentials on revocation
Makes no sense to validate against username and password here, or using
a token to revoke another token, or itself?
In fact, upon further discussion, why do you need credentials to revoke
a token? If you are not supposed to have the token, revoking it seems
the most responsible thing to do with it, so it should be allowed, while
if you are supposed to have it, you should be allowed to revoke it.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 21 Mar 2023 21:57:18 +0100 |
parents | 869df5a6b0c5 |
children |
rev | line source |
---|---|
4400
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
1 local mod_groups = module:depends("groups_internal"); |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
2 |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
3 module:hook("user-registered", function(event) |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
4 local validated_invite = event.validated_invite or (event.session and event.session.validated_invite); |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
5 if not validated_invite then |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
6 -- not registered via invite, nothing to do |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
7 return |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
8 end |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
9 local groups = validated_invite and validated_invite.additional_data and validated_invite.additional_data.groups; |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
10 if not groups then |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
11 -- invite has no groups, nothing to do |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
12 return |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
13 end |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
14 |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
15 local new_username = event.username; |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
16 module:log("debug", "adding %s to groups from invite", new_username); |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
17 for _, group in ipairs(groups) do |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
18 mod_groups.add_member(group, new_username); |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
19 end |
869df5a6b0c5
mod_invites_groups: factor group handling out of mod_invites_register
Jonas Schäfer <jonas@wielicki.name>
parents:
diff
changeset
|
20 end); |