Bug fix: Password length problem

in #utopian-io7 years ago (edited)

Bug Fixes

  • What was the issue(s)?

I had started to create a translation of the project and I found the problem with the password length.
When you are in the registration site it looks that length should be longer then 8.
1.png

But when I clicked into "Register now". It shows 6. Which value is a good one?
2.png

I've checked source code and:
includes/pages/login/ShowRegisterPage.class.php:178

        if(strlen($password) < 6) {
            ...
        }
  • What was the solution?

I've changed the translation, but I think that possibility to change it easily is better. In the future will be possible to change value and use $config->get('')

I changed translations to use sprintf instead of hardcoded values.

$LNG['registerPasswordDesc']        = 'The password must be at least %s characters long.';
...
$LNG['registerErrorPasswordLength'] = 'The password must be at least %s characters long!';

and I've changed the main class to use sprintf:

        if(strlen($password) < 6) {
            $errors[]   = sprintf($LNG['registerErrorPasswordLength'], 6);
        }

Also I've added a new variable for the template:

        $this->assign(array(
            'referralData'      => $referralData,
            'accountName'       => $accountName,
            'externalAuth'      => $externalAuth,
            'universeSelect'    => $universeSelect,
+           'registerPasswordDesc'  => sprintf($LNG['registerPasswordDesc'], 6),
            'registerRulesDesc' => sprintf($LNG['registerRulesDesc'], '<a href="index.php?page=rules">'.$LNG['menu_rules'].'</a>')
        ));
                <label for="password">{$LNG.registerPassword}</label>
                <input type="password" class="input" name="password" id="password">
                {if !empty($error.password)}<span class="error errorPassword"></span>{/if}
-               <span class="inputDesc">{$LNG.registerPasswordDesc}</span>
+               <span class="inputDesc">{$registerPasswordDesc}</span>

Links



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it is too trivial. Please try to improve the length of the code in your next contribution.

You can contact us on Discord.
[utopian-moderator]

Ok. I understand but it can be difficult to fix bug with more lines.

Coin Marketplace

STEEM 0.16
TRX 0.15
JST 0.027
BTC 60256.67
ETH 2327.64
USDT 1.00
SBD 2.46