]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add 'invite-only' mode for registration
authorEvan Prodromou <evan@controlyourself.ca>
Tue, 21 Oct 2008 18:28:22 +0000 (14:28 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Tue, 21 Oct 2008 18:28:22 +0000 (14:28 -0400)
darcs-hash:20081021182822-5ed1f-9a8ee3960f82d115d43e35baac646f69bc702533.gz

README
actions/register.php
config.php.sample
lib/common.php

diff --git a/README b/README
index 311d56480260c1e9aa5f7d3e7b3ae6201dd8b891..150c49ac5dc99cadfabccc5ba3c7b4275b4921c0 100644 (file)
--- a/README
+++ b/README
@@ -688,6 +688,8 @@ closed: If set to 'true', will disallow registration on your site.
        This is a cheap way to restrict accounts to only one
        individual or group; just register the accounts you want on
        the service, *then* set this variable to 'true'.
+inviteonly: If set to 'true', will only allow registration if the user
+           was invited by an existing user.
 
 db
 --
index c370e47276cf4db292149f061261df76a171a2bb..10336d41e60c0c6c37871dd7451d7711e872ecdb 100644 (file)
@@ -59,6 +59,15 @@ class RegisterAction extends Action {
 
                $code = $this->trimmed('code');
 
+               if ($code) {
+                       $invite = Invitation::staticGet($code);
+               }
+               
+               if (common_config('site', 'inviteonly') && !($code && $invite)) {
+                       $this->client_error(_('Sorry, site is invite-only'));
+                       return;
+               }
+               
                # Input scrubbing
 
                $nickname = common_canonical_nickname($nickname);
@@ -149,6 +158,17 @@ class RegisterAction extends Action {
        function show_form($error=NULL) {
                global $config;
 
+               $code = $this->trimmed('code');
+
+               if ($code) {
+                       $invite = Invitation::staticGet($code);
+               }
+               
+               if (common_config('site', 'inviteonly') && !($code && $invite)) {
+                       $this->client_error(_('Sorry, site is invite-only'));
+                       return;
+               }
+               
                common_show_header(_('Register'), NULL, $error, array($this, 'show_top'));
                common_element_start('form', array('method' => 'post',
                                                                                   'id' => 'login',
@@ -156,9 +176,7 @@ class RegisterAction extends Action {
 
                common_hidden('token', common_session_token());
 
-               if ($this->trimmed('code')) {
-                       $code = ($this->trimmed('code'));
-                       $invite = Invitation::staticGet($code);
+               if ($code) {
                        common_hidden('code', $code);
                }
 
index f0394b1ba44d7677abc7945f2d376ff0c37d7f00..d976b523b5f9de5cd742a7ece165153bb5c1dc8e 100644 (file)
@@ -26,6 +26,8 @@ $config['site']['path'] = 'laconica';
 #If you don't want to let users register (say, for a one-person install)
 #Crude but effective -- register everybody, then lock down
 #$config['site']['closed'] = true;
+#Only allow registration for people invited by another user
+#$config['site']['inviteonly'] = true;
 
 # If you want logging sent to a file instead of syslog
 #$config['site']['logfile'] = '/tmp/laconica.log';
index b91b695d807ebf93df1dabee48eab2ff675cad7f..af1d4f251cbd5be2f18dfb682b0f3bc70764ca77 100644 (file)
@@ -67,7 +67,8 @@ $config =
                          'broughtby' => NULL,
                          'timezone' => 'UTC',
                          'broughtbyurl' => NULL,
-                         'closed' => false),
+                         'closed' => false,
+                         'inviteonly' => false),
                'syslog' =>
                array('appname' => 'laconica', # for syslog
                          'priority' => 'debug'), # XXX: currently ignored