Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mrDoctorWho/vk4xmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Smith <mrdoctorwho@helldev.net>2019-02-01 20:21:54 +0300
committerJohn Smith <mrdoctorwho@helldev.net>2019-02-01 20:21:54 +0300
commitb40984006f9410d1fc4db5df30dfd9d325753721 (patch)
tree17d9c55e950654aba2f34521f4e74a8db1d7861e
parentdbec2a5460739af4dac8ba3fdc51d6133380178b (diff)
add ability to disable registration
-rw-r--r--Config_example.txt7
-rw-r--r--library/defaults.py1
-rw-r--r--modules/mod_iq_register.py6
3 files changed, 12 insertions, 2 deletions
diff --git a/Config_example.txt b/Config_example.txt
index fe03bb5..b154742 100644
--- a/Config_example.txt
+++ b/Config_example.txt
@@ -7,7 +7,7 @@ Host = "localhost"
# Connection server (usually equals hostname).
# If your transport runs on the same server as the jabber-server
-# Then it's just "localhost".
+# then it's just "localhost".
Server = "localhost"
# Connection port (as set in Jabber server config).
@@ -63,6 +63,11 @@ URL_ACCEPT_APP = "http://jabberon.ru/vk4xmpp.html#%d"
# Image that will be used if the transport can't recieve image from VK.
URL_VCARD_NO_IMAGE = "https://raw.githubusercontent.com/mrDoctorWho/vk4xmpp/master/vk4xmpp.png"
+# Allow registration.
+# Set to false if you want to forbid registration of new users.
+# Old users will be able to update their registration.
+ALLOW_REGISTRATION = True
+
#! Danger zone.
#! Change the settings below ONLY IF YOU KNOW WHAT ARE YOU DOING! DEFAULT VALUES ARE RECOMMENDED!
# You were warned.
diff --git a/library/defaults.py b/library/defaults.py
index 7363f61..c633373 100644
--- a/library/defaults.py
+++ b/library/defaults.py
@@ -22,6 +22,7 @@ THREAD_STACK_SIZE = 0
VK_ACCESS = 69638
USER_LIMIT = 0
RUN_AS = None
+ALLOW_REGISTRATION = True
IDENTIFIER = {"type": "vk", "category": "gateway", "name": "VK4XMPP Transport", "short": "VK4XMPP"}
URL_ACCEPT_APP = "http://jabberon.ru/vk4xmpp.html#%d"
diff --git a/modules/mod_iq_register.py b/modules/mod_iq_register.py
index 6c49ef2..5fa270f 100644
--- a/modules/mod_iq_register.py
+++ b/modules/mod_iq_register.py
@@ -38,6 +38,10 @@ def register_handler(cl, iq):
sender(cl, utils.buildIQError(iq, xmpp.ERR_NOT_ALLOWED, _("The gateway admins limited registrations, sorry.")))
raise xmpp.NodeProcessed()
+ if not ALLOW_REGISTRATION and source not in Users:
+ sender(cl, utils.buildIQError(iq, xmpp.ERR_NOT_ALLOWED, _("The gateway admins limited registrations, sorry.")))
+ raise xmpp.NodeProcessed()
+
if destination == TransportID and iq.getQueryChildren():
phone, password, use_password, token, result = None, None, None, None, None
query = iq.getTag("query")
@@ -91,7 +95,7 @@ def register_handler(cl, iq):
def sendRegisterForm(cl, iq):
- logger.debug("Send registration form to user (jid: %s)", iq.getFrom().getStripped())
+ logger.debug("Sending registration form to user (jid: %s)", iq.getFrom().getStripped())
form = utils.buildDataForm(fields=forms.Forms.getComlicatedForm(), data=[_("Fill the fields below")])
result = iq.buildReply("result")
result.setQueryPayload([form])