mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Make anonymous auth don't {de}register user when there are other resources
This should fix issue reported in #2878
This commit is contained in:
parent
7d23cd2899
commit
4dc8549738
@ -114,12 +114,18 @@ anonymous_user_exist(User, Server) ->
|
|||||||
%% Register connection
|
%% Register connection
|
||||||
-spec register_connection(ejabberd_sm:sid(), jid(), ejabberd_sm:info()) -> ok.
|
-spec register_connection(ejabberd_sm:sid(), jid(), ejabberd_sm:info()) -> ok.
|
||||||
register_connection(_SID,
|
register_connection(_SID,
|
||||||
#jid{luser = LUser, lserver = LServer}, Info) ->
|
#jid{luser = LUser, lserver = LServer, lresource = LResource}, Info) ->
|
||||||
case proplists:get_value(auth_module, Info) of
|
case proplists:get_value(auth_module, Info) of
|
||||||
?MODULE ->
|
?MODULE ->
|
||||||
|
% Register user only if we are first resource
|
||||||
|
case ejabberd_sm:get_user_resources(LUser, LServer) of
|
||||||
|
[LResource] ->
|
||||||
ejabberd_hooks:run(register_user, LServer, [LUser, LServer]);
|
ejabberd_hooks:run(register_user, LServer, [LUser, LServer]);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Remove an anonymous user from the anonymous users table
|
%% Remove an anonymous user from the anonymous users table
|
||||||
@ -128,9 +134,15 @@ unregister_connection(_SID,
|
|||||||
#jid{luser = LUser, lserver = LServer}, Info) ->
|
#jid{luser = LUser, lserver = LServer}, Info) ->
|
||||||
case proplists:get_value(auth_module, Info) of
|
case proplists:get_value(auth_module, Info) of
|
||||||
?MODULE ->
|
?MODULE ->
|
||||||
|
% Remove user data only if there is no more resources around
|
||||||
|
case ejabberd_sm:get_user_resources(LUser, LServer) of
|
||||||
|
[] ->
|
||||||
ejabberd_hooks:run(remove_user, LServer, [LUser, LServer]);
|
ejabberd_hooks:run(remove_user, LServer, [LUser, LServer]);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% ---------------------------------
|
%% ---------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user