From 4f4c8eb61eba2fcf35e4d6f9e7c13c2576ebe60c Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 26 Apr 2011 22:55:04 +0200 Subject: [PATCH] mod_register Access now also controls account unregistrations --- doc/guide.tex | 9 +++++---- src/mod_register.erl | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/guide.tex b/doc/guide.tex index 5c157aa37..ce57c3c9f 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -3820,10 +3820,11 @@ enables end users to use a \XMPP{} client to: Options: \begin{description} -\titem{\{access, AccessName\}} \ind{options!access}This option can be configured to specify - rules to restrict registration. If a rule returns `deny' on the requested - user name, registration for that user name is denied. (there are no - restrictions by default). +\titem{\{access, AccessName\}} \ind{options!access} + Specify rules to restrict what usernames can be registered and unregistered. + If a rule returns `deny' on the requested username, + registration and unregistration of that user name is denied. + There are no restrictions by default. \titem{\{access\_from, AccessName\}} \ind{options!access\_from}By default, \ejabberd{} doesn't allow to register new accounts from s2s or existing c2s sessions. You can change it by defining access rule in this option. Use with care: allowing registration diff --git a/src/mod_register.erl b/src/mod_register.erl index da1e21bdc..048678373 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -106,8 +106,10 @@ process_iq(From, To, PTag = xml:get_subtag(SubEl, "password"), RTag = xml:get_subtag(SubEl, "remove"), Server = To#jid.lserver, + Access = gen_mod:get_module_opt(Server, ?MODULE, access, all), + AllowRemove = (allow == acl:match_rule(Server, Access, From)), if - (UTag /= false) and (RTag /= false) -> + (UTag /= false) and (RTag /= false) and AllowRemove -> User = xml:get_tag_cdata(UTag), case From of #jid{user = User, lserver = Server} -> @@ -148,7 +150,7 @@ process_iq(From, To, sub_el = [SubEl, ?ERR_BAD_REQUEST]} end end; - (UTag == false) and (RTag /= false) -> + (UTag == false) and (RTag /= false) and AllowRemove -> case From of #jid{user = User, lserver = Server,