changeset 7:781ac4f1e304

Allow others JIDs than super-owners to create nodes.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 26 Aug 2010 23:43:45 +0200
parents 2bcadb0531f4
children efe8dbd34780
files configuration.js psgxs.js
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/configuration.js
+++ b/configuration.js
@@ -24,6 +24,7 @@ config.password = 'hellohello';
 config.superOwner = ['you@example.com'];
 config.version = '0.1';
 config.os = 'GNU/Linux';
+config.allowCreateNode = [/@example\.com$/]; // value is an array of RegExp JIDs. If only super-owner should be able to create nodes, use [].
 
 config.activated = [
 	//'access-authorize',
--- a/psgxs.js
+++ b/psgxs.js
@@ -689,10 +689,17 @@ function onIq(stanza) {
 
 				var bare = toBareJID(to);
 				var right = false;
+
+				// Check for super-owner
 				for (var i in config.owner)
 					if (config.owner[i] == bare)
 						right = true;
 
+				// Check for authorized user
+				for (var i in config.allowCreateNode)
+					if (config.allowCreateNode[i].exec(bare))
+						right = true;
+
 				if (!right)
 					return makeError(response, errors.forbidden.n);