Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Register
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 3 July 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -60,15 +60,23 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( isset( $_SESSION['coppa_user'] ) )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('reg_awaiting_validation');
|
||||
return \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->notCoppaValidated();
|
||||
if ( \IPS\Settings::i()->minimum_age > 0 )
|
||||
{
|
||||
$message = \IPS\Member::loggedIn()->language()->addToStack( 'register_denied_age', FALSE, array( 'sprintf' => array( \IPS\Settings::i()->minimum_age ) ) );
|
||||
\IPS\Output::i()->error( $message, '2C223/7', 403, '' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('reg_awaiting_validation');
|
||||
return \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->notCoppaValidated();
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the step array */
|
||||
$steps = array();
|
||||
|
||||
/* If coppa is enabled we need to add a birthday verification */
|
||||
if ( \IPS\Settings::i()->use_coppa )
|
||||
if ( \IPS\Settings::i()->use_coppa OR \IPS\Settings::i()->minimum_age > 0 )
|
||||
{
|
||||
$steps['coppa'] = function( $data )
|
||||
{
|
||||
@@ -78,7 +86,16 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
if( ( $values['bday']->diff( \IPS\DateTime::create() )->y < 13 ) )
|
||||
/* Did we pass the minimum age requirement? */
|
||||
if ( \IPS\Settings::i()->minimum_age > 0 AND $values['bday']->diff( \IPS\DateTime::create() )->y < \IPS\Settings::i()->minimum_age )
|
||||
{
|
||||
$_SESSION['coppa_user'] = TRUE;
|
||||
|
||||
$message = \IPS\Member::loggedIn()->language()->addToStack( 'register_denied_age', FALSE, array( 'sprintf' => array( \IPS\Settings::i()->minimum_age ) ) );
|
||||
\IPS\Output::i()->error( $message, '2C223/8', 403, '' );
|
||||
}
|
||||
/* We did, but we should check normal COPPA too */
|
||||
else if( ( $values['bday']->diff( \IPS\DateTime::create() )->y < 13 ) )
|
||||
{
|
||||
$_SESSION['coppa_user'] = TRUE;
|
||||
return \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->notCoppaValidated();
|
||||
@@ -100,16 +117,18 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Create Member */
|
||||
$member = \IPS\core\modules\front\system\register::_createMember( $values );
|
||||
|
||||
/* Custom Fields */
|
||||
$profileFields = array();
|
||||
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\REG ) as $group => $fields )
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\Field::REG ) as $group => $fields )
|
||||
{
|
||||
foreach ( $fields as $id => $field )
|
||||
{
|
||||
if( $field->required and ( $values[ $field->name ] === NULL or !isset( $values[ $field->name ] ) ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'reg_required_fields', '1C223/5', 403, '' );
|
||||
}
|
||||
|
||||
$profileFields[ "field_{$id}" ] = $field::stringValue( $values[ $field->name ] );
|
||||
|
||||
if ( $fields instanceof \IPS\Helpers\Form\Editor )
|
||||
@@ -118,33 +137,46 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
\IPS\Db::i()->replace( 'core_pfields_content', array_merge( array( 'member_id' => $member->member_id ), $profileFields ) );
|
||||
|
||||
/* Email - We don't want to send if the new member is banned or we're not using email validation */
|
||||
if( \IPS\Settings::i()->reg_auth_type != 'none' AND \IPS\Settings::i()->reg_auth_type != 'admin' AND !$member->members_bitoptions['bw_is_spammer'] )
|
||||
if ( \IPS\Settings::i()->security_questions_enabled and ( \IPS\Settings::i()->security_questions_prompt === 'register' or ( \IPS\Settings::i()->security_questions_prompt === 'optional' and !$values['security_questions_optout_title'] ) ) )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'core', 'registration_validate', array( $member, \IPS\Db::i()->select( 'vid', 'core_validating', array( 'member_id=?', $member->member_id ) )->first() ) )->send( $member );
|
||||
$answers = array();
|
||||
foreach ( $values as $k => $v )
|
||||
{
|
||||
if ( preg_match( '/^security_question_q_(\d+)$/', $k, $matches ) )
|
||||
{
|
||||
if ( isset( $answers[ $v ] ) )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'security_questions_unique', FALSE, array( 'pluralize' => array( \IPS\Settings::i()->security_questions_number ?: 3 ) ) );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
$answers[ $v ] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Notify the incoming mail address except if they're a spammer */
|
||||
if( \IPS\Settings::i()->new_reg_notify && !$member->members_bitoptions['bw_is_spammer'] )
|
||||
if ( !$form->error )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'core', 'registration_notify', array( $member, $profileFields ) )->send( \IPS\Settings::i()->email_in );
|
||||
}
|
||||
|
||||
/* Log them in */
|
||||
\IPS\Session::i()->setMember( $member );
|
||||
|
||||
$redirectUrl = \IPS\Login::getRegistrationDestination( $member );
|
||||
|
||||
/* Redirect */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'redirect' => (string) $redirectUrl ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $redirectUrl );
|
||||
/* Create Member */
|
||||
$member = \IPS\core\modules\front\system\register::_createMember( $values, $profileFields );
|
||||
|
||||
/* Log them in */
|
||||
\IPS\Session::i()->setMember( $member );
|
||||
|
||||
$redirectUrl = \IPS\Login::getRegistrationDestination( $member );
|
||||
|
||||
/* Redirect */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'redirect' => (string) $redirectUrl ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $redirectUrl );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,12 +200,12 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form( 'form', 'register_button', NULL, array( 'data-controller' => 'core.front.system.register') );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'username', NULL, TRUE, array( 'accountUsername' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'email_address', NULL, TRUE, array( 'accountEmail' => TRUE, 'maxLength' => 150 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'password', NULL, TRUE, array() ) );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'email_address', NULL, TRUE, array( 'accountEmail' => TRUE, 'maxLength' => 150, 'bypassProfanity' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'password', NULL, TRUE, array( 'showMeter' => \IPS\Settings::i()->password_strength_meter, 'checkStrength' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'password_confirm', NULL, TRUE, array( 'confirm' => 'password' ) ) );
|
||||
|
||||
/* Profile fields */
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\REG ) as $group => $fields )
|
||||
foreach ( \IPS\core\ProfileFields\Field::fields( array(), \IPS\core\ProfileFields\Field::REG ) as $group => $fields )
|
||||
{
|
||||
foreach ( $fields as $field )
|
||||
{
|
||||
@@ -189,6 +221,54 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
catch ( \UnderflowException $e ) {}
|
||||
|
||||
/* Security Questions */
|
||||
if ( \IPS\Settings::i()->security_questions_enabled and in_array( \IPS\Settings::i()->security_questions_prompt, array( 'register', 'optional' ) ) )
|
||||
{
|
||||
$numberOfQuestions = \IPS\Settings::i()->security_questions_number ?: 3;
|
||||
$securityQuestions = array();
|
||||
foreach ( \IPS\MFA\SecurityQuestions\Question::roots() as $securityQuestion )
|
||||
{
|
||||
$securityQuestions[ $securityQuestion->id ] = $securityQuestion->_title;
|
||||
}
|
||||
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('security_questions_setup_blurb', FALSE, array( 'pluralize' => array( $numberOfQuestions ) ) ) );
|
||||
if ( \IPS\Settings::i()->security_questions_prompt === 'optional' )
|
||||
{
|
||||
$securityOptoutToggles = array();
|
||||
foreach ( range( 1, min( $numberOfQuestions, count( $securityQuestions ) ) ) as $i )
|
||||
{
|
||||
$securityOptoutToggles[] = 'security_question_q_' . $i;
|
||||
$securityOptoutToggles[] = 'security_question_a_' . $i;
|
||||
}
|
||||
|
||||
$optOutCheckbox = new \IPS\Helpers\Form\Checkbox( 'security_questions_optout_title', FALSE, FALSE, array( 'togglesOff' => $securityOptoutToggles ) );
|
||||
if ( \IPS\Member::loggedIn()->language()->checkKeyExists('security_questions_opt_out_warning_value') )
|
||||
{
|
||||
$optOutCheckbox->description = \IPS\Member::loggedIn()->language()->addToStack('security_questions_opt_out_warning_value');
|
||||
}
|
||||
$form->add( $optOutCheckbox );
|
||||
}
|
||||
foreach ( range( 1, min( $numberOfQuestions, count( $securityQuestions ) ) ) as $i )
|
||||
{
|
||||
$securityValidation = function( $val ) {
|
||||
if ( !$val and ( \IPS\Settings::i()->security_questions_prompt === 'register' or !isset( \IPS\Request::i()->security_questions_optout_title_checkbox ) ) )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
}
|
||||
};
|
||||
|
||||
$questionField = new \IPS\Helpers\Form\Select( 'security_question_q_' . $i, NULL, FALSE, array( 'options' => $securityQuestions ), $securityValidation, NULL, NULL, 'security_question_q_' . $i );
|
||||
$questionField->label = \IPS\Member::loggedIn()->language()->addToStack('security_question_q');
|
||||
|
||||
$answerField = new \IPS\Helpers\Form\Text( 'security_question_a_' . $i, NULL, NULL, array(), $securityValidation, NULL, NULL, 'security_question_a_' . $i );
|
||||
$answerField->label = \IPS\Member::loggedIn()->language()->addToStack('security_question_a');
|
||||
|
||||
$form->add( $questionField );
|
||||
$form->add( $answerField );
|
||||
}
|
||||
$form->addSeparator();
|
||||
}
|
||||
|
||||
/* Random Q&A */
|
||||
if( $question )
|
||||
{
|
||||
@@ -280,10 +360,11 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Create Member
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param array $values Values from form
|
||||
* @param array $profileFields Profile field values from registration
|
||||
* @return \IPS\Member
|
||||
*/
|
||||
public static function _createMember( $values )
|
||||
public static function _createMember( $values, $profileFields )
|
||||
{
|
||||
/* Create */
|
||||
$member = new \IPS\Member;
|
||||
@@ -303,15 +384,50 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'spam_denied_account', '2S129/1', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Will we be validating? */
|
||||
if ( \IPS\Settings::i()->reg_auth_type != 'none' )
|
||||
|
||||
/* Save */
|
||||
$member->save();
|
||||
|
||||
/* Security Questions */
|
||||
if ( \IPS\Settings::i()->security_questions_enabled and in_array( \IPS\Settings::i()->security_questions_prompt, array( 'register', 'optional' ) ) )
|
||||
{
|
||||
$member->members_bitoptions['validating'] = TRUE;
|
||||
if ( $values['security_questions_optout_title'] )
|
||||
{
|
||||
$member->members_bitoptions['security_questions_opt_out'] = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$answers = array();
|
||||
|
||||
foreach ( $values as $k => $v )
|
||||
{
|
||||
if ( preg_match( '/^security_question_q_(\d+)$/', $k, $matches ) )
|
||||
{
|
||||
$answers[ $v ] = array(
|
||||
'answer_question_id' => $v,
|
||||
'answer_member_id' => $member->member_id,
|
||||
'answer_answer' => \IPS\Text\Encrypt::fromPlaintext( $values[ 'security_question_a_' . $matches[1] ] )->tag()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $answers ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_security_answers', $answers );
|
||||
}
|
||||
|
||||
$member->members_bitoptions['has_security_answers'] = TRUE;
|
||||
}
|
||||
$member->save();
|
||||
}
|
||||
|
||||
/* Save custom field values */
|
||||
\IPS\Db::i()->replace( 'core_pfields_content', array_merge( array( 'member_id' => $member->member_id ), $profileFields ) );
|
||||
|
||||
/* Handle validation */
|
||||
$member->postRegistration();
|
||||
|
||||
/* Save and return */
|
||||
$member->save();
|
||||
return $member;
|
||||
}
|
||||
|
||||
@@ -370,6 +486,8 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function resend()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$validating = \IPS\Db::i()->select( '*', 'core_validating', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) );
|
||||
|
||||
if ( !count( $validating ) )
|
||||
@@ -379,7 +497,14 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach( $validating as $reg )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'core', 'registration_validate', array( \IPS\Member::loggedIn(), $reg['vid'] ) )->send( \IPS\Member::loggedIn() );
|
||||
if ( $reg['email_sent'] and $reg['email_sent'] > ( time() - 900 ) )
|
||||
{
|
||||
\IPS\Output::i()->error( \IPS\Member::loggedIn()->language()->addToStack('validation_email_rate_limit', FALSE, array( 'sprintf' => array( \IPS\DateTime::ts( $reg['email_sent'] )->relative( \IPS\DateTime::RELATIVE_FORMAT_LOWER ) ) ) ), '1C223/4', 429, '', array( 'Retry-After' => \IPS\DateTime::ts( $reg['email_sent'] )->add( new \DateInterval( 'PT15M' ) )->format('r') ) );
|
||||
}
|
||||
|
||||
\IPS\Email::buildFromTemplate( 'core', $reg['email_chg'] ? 'email_change' : 'registration_validate', array( \IPS\Member::loggedIn(), $reg['vid'] ), \IPS\Email::TYPE_TRANSACTIONAL )->send( \IPS\Member::loggedIn() );
|
||||
|
||||
\IPS\Db::i()->update( 'core_validating', array( 'email_sent' => time() ), array( 'vid=?', $reg['vid'] ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=register&do=validating', 'front', 'register' ), 'reg_email_resent' );
|
||||
@@ -394,6 +519,7 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if( \IPS\Request::i()->vid AND \IPS\Request::i()->mid )
|
||||
{
|
||||
/* Load record */
|
||||
try
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'core_validating', array( 'vid=? AND member_id=? AND ( new_reg=? or email_chg=? )', \IPS\Request::i()->vid, \IPS\Request::i()->mid, 1, 1 ) )->first();
|
||||
@@ -403,18 +529,26 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'validate_no_record', '2S129/2', 404, '' );
|
||||
}
|
||||
|
||||
/* If we're using user validation, or this was anything other than a new registration (like an email change) we can go ahead and validate */
|
||||
if( \IPS\Settings::i()->reg_auth_type == 'user' or $record['email_chg'] )
|
||||
/* Validate */
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->mid );
|
||||
if ( $record['new_reg'] )
|
||||
{
|
||||
\IPS\Member::load( \IPS\Request::i()->mid )->validate();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ), 'validate_confirmation' );
|
||||
$member->emailValidationConfirmed( $record );
|
||||
}
|
||||
/* Otherwise admin still needs to validate so we flag user validated */
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_validating', array( 'user_verified' => TRUE ), array( 'member_id=?', \IPS\Request::i()->mid ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ), 'validate_email_confirmation' );
|
||||
$member->members_bitoptions['validating'] = FALSE;
|
||||
$member->save();
|
||||
|
||||
\IPS\Db::i()->delete( 'core_validating', array( 'member_id=?', $member->member_id ) );
|
||||
|
||||
/* Send a confirmation email */
|
||||
\IPS\Email::buildFromTemplate( 'core', 'email_address_changed', array( $member, $record['prev_email'] ), \IPS\Email::TYPE_TRANSACTIONAL )->send( $record['prev_email'], array(), array(), NULL, NULL, array( 'Reply-To' => \IPS\Settings::i()->email_in ) );
|
||||
}
|
||||
|
||||
/* Log in and Redirect */
|
||||
\IPS\Session::i()->setMember( $member );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ), 'validate_email_confirmation' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,8 +559,22 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function complete()
|
||||
{
|
||||
/* Check we are an incomplete member */
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=login', 'front', 'login', NULL, \IPS\Settings::i()->logins_over_https ) );
|
||||
}
|
||||
elseif ( \IPS\Member::loggedIn()->real_name and \IPS\Member::loggedIn()->email )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ) );
|
||||
}
|
||||
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form( 'form', 'register_button' );
|
||||
if ( isset( \IPS\Request::i()->ref ) )
|
||||
{
|
||||
$form->hiddenValues['ref'] = \IPS\Request::i()->ref;
|
||||
}
|
||||
if( !\IPS\Member::loggedIn()->real_name OR \IPS\Member::loggedIn()->name === \IPS\Member::loggedIn()->language()->get('guest') )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'username', NULL, TRUE, array( 'accountUsername' => \IPS\Member::loggedIn() ) ) );
|
||||
@@ -463,30 +611,19 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'spam_denied_account', '2S272/1', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/* If email validation is enabled add a validating record */
|
||||
if( in_array( \IPS\Settings::i()->reg_auth_type, array( 'user', 'admin_user' ) ) )
|
||||
{
|
||||
$vid = md5( uniqid() );
|
||||
|
||||
\IPS\Db::i()->insert( 'core_validating', array(
|
||||
'vid' => $vid,
|
||||
'member_id' => \IPS\Member::loggedIn()->member_id,
|
||||
'entry_date' => time(),
|
||||
'new_reg' => 1,
|
||||
'email_chg' => 0,
|
||||
'user_verified' => FALSE,
|
||||
'ip_address' => \IPS\Request::i()->ipAddress()
|
||||
) );
|
||||
|
||||
\IPS\Member::loggedIn()->members_bitoptions['validating'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Save */
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ) );
|
||||
|
||||
/* Handle validation */
|
||||
\IPS\Member::loggedIn()->postRegistration( ( isset( $values['email_address'] ) ) ? FALSE : TRUE );
|
||||
|
||||
/* Set member as a full member in the session table */
|
||||
\IPS\Session::i()->setType( \IPS\Session\Front::LOGIN_TYPE_MEMBER );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Login::getRegistrationDestination( \IPS\Member::loggedIn() ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('reg_complete_details');
|
||||
@@ -518,43 +655,55 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Build the form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'new_email', '', TRUE, array( 'accountEmail' => TRUE ) ) );
|
||||
$captcha = new \IPS\Helpers\Form\Captcha;
|
||||
if ( (string) $captcha !== '' )
|
||||
{
|
||||
$form->add( $captcha );
|
||||
}
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Change the email */
|
||||
$oldEmail = \IPS\Member::loggedIn()->email;
|
||||
foreach ( \IPS\Login::handlers( TRUE ) as $handler )
|
||||
{
|
||||
try
|
||||
{
|
||||
$handler->changeEmail( \IPS\Member::loggedIn(), \IPS\Member::loggedIn()->email, $values['new_email'] );
|
||||
$handler->changeEmail( \IPS\Member::loggedIn(), $oldEmail, $values['new_email'] );
|
||||
}
|
||||
catch( \BadMethodCallException $e ) {}
|
||||
}
|
||||
|
||||
/* Delete any pending validation emails */
|
||||
if ( $pending['vid'] )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_validating', array( 'member_id=? AND ( new_reg=1 or email_chg=1 )', \IPS\Member::loggedIn()->member_id ) );
|
||||
}
|
||||
|
||||
$vid = md5( uniqid() );
|
||||
|
||||
\IPS\Db::i()->insert( 'core_validating', array(
|
||||
'vid' => $vid,
|
||||
'member_id' => \IPS\Member::loggedIn()->member_id,
|
||||
'entry_date' => time(),
|
||||
'new_reg' => !$pending or $pending['new_reg'],
|
||||
'email_chg' => $pending and $pending['email_chg'],
|
||||
'user_verified' => ( \IPS\Settings::i()->reg_auth_type == 'admin' ) ?: FALSE,
|
||||
'ip_address' => \IPS\Request::i()->ipAddress()
|
||||
) );
|
||||
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
\IPS\Email::buildFromTemplate( 'core', 'registration_validate', array( \IPS\Member::loggedIn(), $vid ) )->send( \IPS\Member::loggedIn() );
|
||||
|
||||
|
||||
/* If email validation is required, do that... */
|
||||
if ( in_array( \IPS\Settings::i()->reg_auth_type, array( 'user', 'admin_user' ) ) )
|
||||
{
|
||||
/* Delete any pending validation emails */
|
||||
if ( $pending['vid'] )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_validating', array( 'member_id=? AND ( new_reg=1 or email_chg=1 )', \IPS\Member::loggedIn()->member_id ) );
|
||||
}
|
||||
|
||||
$vid = \IPS\Login::generateRandomString();
|
||||
|
||||
\IPS\Db::i()->insert( 'core_validating', array(
|
||||
'vid' => $vid,
|
||||
'member_id' => \IPS\Member::loggedIn()->member_id,
|
||||
'entry_date' => time(),
|
||||
'new_reg' => !$pending or $pending['new_reg'],
|
||||
'email_chg' => $pending and $pending['email_chg'],
|
||||
'user_verified' => ( \IPS\Settings::i()->reg_auth_type == 'admin' ) ?: FALSE,
|
||||
'ip_address' => \IPS\Request::i()->ipAddress(),
|
||||
'email_sent' => time(),
|
||||
) );
|
||||
|
||||
\IPS\Email::buildFromTemplate( 'core', $pending['email_chg'] ? 'email_change' : 'registration_validate', array( \IPS\Member::loggedIn(), $vid ), \IPS\Email::TYPE_TRANSACTIONAL )->send( \IPS\Member::loggedIn() );
|
||||
}
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ) );
|
||||
}
|
||||
|
||||
@@ -575,8 +724,46 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2C223/1', 403, '' );
|
||||
}
|
||||
|
||||
/* Delete Member */
|
||||
\IPS\Member::loggedIn()->delete();
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete( 'reg_cancel', 'reg_cancel_confirm', 'reg_cancel' );
|
||||
|
||||
/* Log the user out. Previously, we immediately deleted the account however this has been changed to let the cleanup task handle this instead. */
|
||||
\IPS\Request::i()->setCookie( 'member_id', NULL );
|
||||
\IPS\Request::i()->setCookie( 'pass_hash', NULL );
|
||||
\IPS\Request::i()->setCookie( 'anon_login', NULL );
|
||||
|
||||
foreach( \IPS\Request::i()->cookie as $name => $value )
|
||||
{
|
||||
if( mb_strpos( $name, "ipbforumpass_" ) !== FALSE )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( $name, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset session global parameters */
|
||||
$_SESSION = array();
|
||||
|
||||
/* We have to explicitly reset the session cookie
|
||||
@link http://php.net/manual/en/function.session-destroy.php */
|
||||
$params = session_get_cookie_params();
|
||||
|
||||
setcookie( session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] );
|
||||
|
||||
/* Then destroy the session itself */
|
||||
session_destroy();
|
||||
|
||||
/* Member sync callback */
|
||||
\IPS\Member::loggedIn()->memberSync( 'onLogout', array( \IPS\Http\Url::internal( '' ) ) );
|
||||
|
||||
/* Login handler callback */
|
||||
foreach ( \IPS\Login::handlers( TRUE ) as $k => $handler )
|
||||
{
|
||||
try
|
||||
{
|
||||
$handler->logoutAccount( \IPS\Member::loggedIn(), \IPS\Http\Url::internal( '' ) );
|
||||
}
|
||||
catch( \BadMethodCallException $e ) {}
|
||||
}
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ), 'reg_canceled' );
|
||||
@@ -591,6 +778,10 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* Generate form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
if ( isset( \IPS\Request::i()->ref ) )
|
||||
{
|
||||
$form->hiddenValues['ref'] = \IPS\Request::i()->ref;
|
||||
}
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'reconfirm_checkbox', NULL, FALSE, array(), function( $val )
|
||||
{
|
||||
@@ -607,6 +798,19 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
\IPS\Member::loggedIn()->members_bitoptions['must_reaccept_terms'] = FALSE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
if ( isset( \IPS\Request::i()->ref ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$ref = \IPS\Http\Url\Friendly::createFromString( base64_decode( \IPS\Request::i()->ref ) );
|
||||
if ( $ref instanceof \IPS\Http\Url\Internal )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $ref );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('') );
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user