add 'invite-only' mode for registration

darcs-hash:20081021182822-5ed1f-9a8ee3960f82d115d43e35baac646f69bc702533.gz
This commit is contained in:
Evan Prodromou 2008-10-21 14:28:22 -04:00
parent 44a90a7fa7
commit 3a246c1726
4 changed files with 27 additions and 4 deletions

2
README
View File

@ -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 This is a cheap way to restrict accounts to only one
individual or group; just register the accounts you want on individual or group; just register the accounts you want on
the service, *then* set this variable to 'true'. 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 db
-- --

View File

@ -59,6 +59,15 @@ class RegisterAction extends Action {
$code = $this->trimmed('code'); $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 # Input scrubbing
$nickname = common_canonical_nickname($nickname); $nickname = common_canonical_nickname($nickname);
@ -149,6 +158,17 @@ class RegisterAction extends Action {
function show_form($error=NULL) { function show_form($error=NULL) {
global $config; 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_show_header(_('Register'), NULL, $error, array($this, 'show_top'));
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',
'id' => 'login', 'id' => 'login',
@ -156,9 +176,7 @@ class RegisterAction extends Action {
common_hidden('token', common_session_token()); common_hidden('token', common_session_token());
if ($this->trimmed('code')) { if ($code) {
$code = ($this->trimmed('code'));
$invite = Invitation::staticGet($code);
common_hidden('code', $code); common_hidden('code', $code);
} }

View File

@ -26,6 +26,8 @@ $config['site']['path'] = 'laconica';
#If you don't want to let users register (say, for a one-person install) #If you don't want to let users register (say, for a one-person install)
#Crude but effective -- register everybody, then lock down #Crude but effective -- register everybody, then lock down
#$config['site']['closed'] = true; #$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 # If you want logging sent to a file instead of syslog
#$config['site']['logfile'] = '/tmp/laconica.log'; #$config['site']['logfile'] = '/tmp/laconica.log';

View File

@ -67,7 +67,8 @@ $config =
'broughtby' => NULL, 'broughtby' => NULL,
'timezone' => 'UTC', 'timezone' => 'UTC',
'broughtbyurl' => NULL, 'broughtbyurl' => NULL,
'closed' => false), 'closed' => false,
'inviteonly' => false),
'syslog' => 'syslog' =>
array('appname' => 'laconica', # for syslog array('appname' => 'laconica', # for syslog
'priority' => 'debug'), # XXX: currently ignored 'priority' => 'debug'), # XXX: currently ignored