Bug fix: Password length problem

in utopian-io •  4 months ago

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.

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

I've checked source code and:

        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:

            '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>


Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

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.


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