Added new acl for mod_register: access_from. This acl is applied if existing account...
authorEvgeniy Khramtsov <xramtsov@gmail.com>
Sun, 31 Jan 2010 13:55:10 +0000 (13:55 +0000)
committerEvgeniy Khramtsov <xramtsov@gmail.com>
Sun, 31 Jan 2010 13:55:10 +0000 (13:55 +0000)
SVN Revision: 2949

src/mod_register.erl

index 1da55253c85e59df9dc6b1709e6a5e8d231ea21a..2a6c7c20bb1640baed5ec57b420010c9d6007b13 100644 (file)
@@ -166,13 +166,20 @@ process_iq(From, To,
                        #jid{user = User, lserver = Server} ->
                            try_set_password(User, Server, Password, IQ, SubEl);
                        _ ->
-                           case try_register(User, Server, Password,
-                                             Source, Lang) of
-                               ok ->
-                                   IQ#iq{type = result, sub_el = [SubEl]};
-                               {error, Error} ->
+                           case check_from(From, Server) of
+                               allow ->
+                                   case try_register(User, Server, Password,
+                                                     Source, Lang) of
+                                       ok ->
+                                           IQ#iq{type = result,
+                                                 sub_el = [SubEl]};
+                                       {error, Error} ->
+                                           IQ#iq{type = error,
+                                                 sub_el = [SubEl, Error]}
+                                   end;
+                               deny ->
                                    IQ#iq{type = error,
-                                         sub_el = [SubEl, Error]}
+                                         sub_el = [SubEl, ?ERR_FORBIDDEN]}
                            end
                    end;
                true ->
@@ -293,6 +300,11 @@ send_registration_notifications(UJID, Source) ->
            ok
     end.
 
+check_from(#jid{user = "", server = ""}, _Server) ->
+    allow;
+check_from(JID, Server) ->
+    Access = gen_mod:get_module_opt(Server, ?MODULE, access_from, none),
+    acl:match_rule(Server, Access, JID).
 
 check_timeout(undefined) ->
     true;