store invite code in session so openidfinish can find it
This commit is contained in:
		@@ -191,11 +191,28 @@ class FinishopenidloginAction extends Action
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        # FIXME: save invite code before redirect, and check here
 | 
					        # FIXME: save invite code before redirect, and check here
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
 | 
					        if (common_config('site', 'closed')) {
 | 
				
			||||||
            $this->clientError(_('Registration not allowed.'));
 | 
					            $this->clientError(_('Registration not allowed.'));
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $invite = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (common_config('site', 'inviteonly')) {
 | 
				
			||||||
 | 
					            $code = $_SESSION['invitecode'];
 | 
				
			||||||
 | 
					            if (empty($code)) {
 | 
				
			||||||
 | 
					                $this->clientError(_('Registration not allowed.'));
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $invite = Invitation::staticGet($code);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (empty($invite)) {
 | 
				
			||||||
 | 
					                $this->clientError(_('Not a valid invitation code.'));
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $nickname = $this->trimmed('newname');
 | 
					        $nickname = $this->trimmed('newname');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!Validate::string($nickname, array('min_length' => 1,
 | 
					        if (!Validate::string($nickname, array('min_length' => 1,
 | 
				
			||||||
@@ -257,10 +274,16 @@ class FinishopenidloginAction extends Action
 | 
				
			|||||||
        # XXX: add language
 | 
					        # XXX: add language
 | 
				
			||||||
        # XXX: add timezone
 | 
					        # XXX: add timezone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $user = User::register(array('nickname' => $nickname,
 | 
					        $args = array('nickname' => $nickname,
 | 
				
			||||||
                      'email' => $email,
 | 
					                      'email' => $email,
 | 
				
			||||||
                      'fullname' => $fullname,
 | 
					                      'fullname' => $fullname,
 | 
				
			||||||
                                     'location' => $location));
 | 
					                      'location' => $location);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!empty($invite)) {
 | 
				
			||||||
 | 
					            $args['code'] = $invite->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $user = User::register($args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $result = oid_link_user($user->id, $canonical, $display);
 | 
					        $result = oid_link_user($user->id, $canonical, $display);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,6 +55,44 @@ class RegisterAction extends Action
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    var $registered = false;
 | 
					    var $registered = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Prepare page to run
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param $args
 | 
				
			||||||
 | 
					     * @return string title
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function prepare()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->code = $this->trimmed('code');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (empty($this->code)) {
 | 
				
			||||||
 | 
					            common_ensure_session();
 | 
				
			||||||
 | 
					            if (!empty($_SESSION['invitecode'])) {
 | 
				
			||||||
 | 
					                $this->code = $_SESSION['invitecode'];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (common_config('site', 'inviteonly') && empty($this->code)) {
 | 
				
			||||||
 | 
					            $this->clientError(_('Sorry, only invited people can register.'));
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!empty($this->code)) {
 | 
				
			||||||
 | 
					            $this->invite = Invitation::staticGet($code);
 | 
				
			||||||
 | 
					            if (empty($this->invite)) {
 | 
				
			||||||
 | 
					                $this->clientError(_('Sorry, invalid invitation code.'));
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // Store this in case we need it
 | 
				
			||||||
 | 
					            common_ensure_session();
 | 
				
			||||||
 | 
					            $_SESSION['invitecode'] = $this->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Title of the page
 | 
					     * Title of the page
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -343,17 +381,6 @@ class RegisterAction extends Action
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    function showFormContent()
 | 
					    function showFormContent()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $code = $this->trimmed('code');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($code) {
 | 
					 | 
				
			||||||
            $invite = Invitation::staticGet($code);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (common_config('site', 'inviteonly') && !($code && $invite)) {
 | 
					 | 
				
			||||||
            $this->clientError(_('Sorry, only invited people can register.'));
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->elementStart('form', array('method' => 'post',
 | 
					        $this->elementStart('form', array('method' => 'post',
 | 
				
			||||||
                                          'id' => 'form_register',
 | 
					                                          'id' => 'form_register',
 | 
				
			||||||
                                          'class' => 'form_settings',
 | 
					                                          'class' => 'form_settings',
 | 
				
			||||||
@@ -362,8 +389,8 @@ class RegisterAction extends Action
 | 
				
			|||||||
        $this->element('legend', null, 'Account settings');
 | 
					        $this->element('legend', null, 'Account settings');
 | 
				
			||||||
        $this->hidden('token', common_session_token());
 | 
					        $this->hidden('token', common_session_token());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($code) {
 | 
					        if ($this->code) {
 | 
				
			||||||
            $this->hidden('code', $code);
 | 
					            $this->hidden('code', $this->code);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->elementStart('ul', 'form_data');
 | 
					        $this->elementStart('ul', 'form_data');
 | 
				
			||||||
@@ -382,8 +409,8 @@ class RegisterAction extends Action
 | 
				
			|||||||
                            _('Same as password above. Required.'));
 | 
					                            _('Same as password above. Required.'));
 | 
				
			||||||
            $this->elementEnd('li');
 | 
					            $this->elementEnd('li');
 | 
				
			||||||
            $this->elementStart('li');
 | 
					            $this->elementStart('li');
 | 
				
			||||||
            if ($invite && $invite->address_type == 'email') {
 | 
					            if ($this->invite && $this->invite->address_type == 'email') {
 | 
				
			||||||
                $this->input('email', _('Email'), $invite->address,
 | 
					                $this->input('email', _('Email'), $this->invite->address,
 | 
				
			||||||
                             _('Used only for updates, announcements, '.
 | 
					                             _('Used only for updates, announcements, '.
 | 
				
			||||||
                               'and password recovery'));
 | 
					                               'and password recovery'));
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user