25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Validate affiliations in set_room_affiliation command

This commit is contained in:
Paweł Chmielowski 2021-01-21 14:20:30 +01:00
parent a4b06df604
commit 5212b0aaa6

View File

@ -1237,7 +1237,15 @@ get_room_affiliation(Name, Service, JID) ->
%% If the affiliation is 'none', the action is to remove,
%% In any other case the action will be to create the affiliation.
set_room_affiliation(Name, Service, JID, AffiliationString) ->
Affiliation = misc:binary_to_atom(AffiliationString),
Affiliation = case AffiliationString of
<<"outcast">> -> outcast;
<<"none">> -> none;
<<"member">> -> member;
<<"admin">> -> admin;
<<"owner">> -> owner;
_ ->
throw({error, "Invalid affiliation"})
end,
case get_room_pid(Name, Service) of
Pid when is_pid(Pid) ->
%% Get the PID for the online room so we can get the state of the room