[UPDATE] config option for register with valid coin address

This commit is contained in:
iAmShorty 2014-05-28 15:20:49 +02:00
parent 81f632c646
commit c4ecd18052
5 changed files with 23 additions and 7 deletions

View File

@ -741,9 +741,11 @@ class User extends Base {
$this->setErrorMessage('Username exceeding character limit');
return false;
}
if (!$this->bitcoin->validateaddress($coinaddress)) {
$this->setErrorMessage('Coin address is not valid');
return false;
if (!is_null($coinaddress)) {
if (!$this->bitcoin->validateaddress($coinaddress)) {
$this->setErrorMessage('Coin address is not valid');
return false;
}
}
if (preg_match('/[^a-z_\-0-9]/i', $username)) {
$this->setErrorMessage('Username may only contain alphanumeric characters');
@ -841,7 +843,7 @@ class User extends Base {
} else {
$this->setErrorMessage( 'Unable to register' );
$this->debug->append('Failed to insert user into DB: ' . $this->mysqli->error);
if ($stmt->sqlstate == '23000') $this->setErrorMessage( 'Username or email already registered' );
if ($stmt->sqlstate == '23000') $this->setErrorMessage( 'Username, email or Coinaddress already registered' );
return false;
}
return false;

View File

@ -15,6 +15,12 @@ $config['version_url'] = 'https://raw.githubusercontent.com/MPOS/php-mpos/master
*/
$config['skip_config_tests'] = false;
/**
* Unless you disable this, we'll do a check for a valid coin address on registration.
* https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-coin-address-check
*/
$config['check_valid_coinaddress'] = true;
/**
* Defines
* Debug setting and salts for hashing passwords

View File

@ -26,10 +26,15 @@ if ($setting->getValue('disable_invitations') && $setting->getValue('lock_regist
if ($setting->getValue('recaptcha_enabled') != 1 || $setting->getValue('recaptcha_enabled_registrations') != 1 || $rsp->is_valid) {
// Check if recaptcha is enabled, process form data if valid or disabled
isset($_POST['token']) ? $token = $_POST['token'] : $token = '';
if ($user->register(@$_POST['username'], @$_POST['coinaddress'], @$_POST['password1'], @$_POST['password2'], @$_POST['pin'], @$_POST['email1'], @$_POST['email2'], @$_POST['tac'], $token)) {
(!$setting->getValue('accounts_confirm_email_disabled')) ? $_SESSION['POPUP'][] = array('CONTENT' => 'Please check your mailbox to activate this account') : $_SESSION['POPUP'][] = array('CONTENT' => 'Account created, please login');
isset($_POST['coinaddress']) ? $validcoinaddress = $_POST['coinaddress'] : $validcoinaddress = NULL;
if ($config['check_valid_coinaddress'] AND empty($validcoinaddress)) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Please enter a valid Wallet Address', 'TYPE' => 'alert alert-danger');
} else {
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to create account: ' . $user->getError(), 'TYPE' => 'alert alert-danger');
if ($user->register(@$_POST['username'], $validcoinaddress, @$_POST['password1'], @$_POST['password2'], @$_POST['pin'], @$_POST['email1'], @$_POST['email2'], @$_POST['tac'], $token)) {
(!$setting->getValue('accounts_confirm_email_disabled')) ? $_SESSION['POPUP'][] = array('CONTENT' => 'Please check your mailbox to activate this account') : $_SESSION['POPUP'][] = array('CONTENT' => 'Account created, please login');
} else {
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to create account: ' . $user->getError(), 'TYPE' => 'alert alert-danger');
}
}
}
} else {

View File

@ -63,6 +63,7 @@ $aGlobal = array(
'reward' => $config['reward_type'] == 'fixed' ? $config['reward'] : $block->getAverageAmount(),
'price' => $setting->getValue('price'),
'twofactor' => $config['twofactor'],
'coinaddresscheck' => $config['check_valid_coinaddress'],
'csrf' => $config['csrf'],
'config' => array(
'date' => $setting->getValue('system_date_format', '%m/%d/%Y %H:%M:%S'),

View File

@ -22,11 +22,13 @@
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
<input type="text" class="form-control" name="username" placeholder="Username" value="{$smarty.post.username|escape|default:""}" size="15" maxlength="20" required>
</div>
{if $GLOBAL.coinaddresscheck|default:"1"}
<label>Coin Address</label>
<div class="input-group input-group-sm">
<span class="input-group-addon"><i class="fa fa-money fa-fw"></i></span>
<input type="text" name="coinaddress" placeholder="Coin Address" class="form-control" value="{$smarty.post.coinaddress|escape|default:""}" size="15" required>
</div>
{/if}
<label>Password</label> (<span id="pw_strength">Strength</span>)
<div class="input-group input-group-sm">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>