sfPasswordStrengthPlugin - 0.1.3

sfPasswordStrengthPlugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source | Show as Markdown

sfPasswordStrengthPlugin plugin

The sfPasswordStrengthPlugin allows you to easily measure the strength of a password.

It is displayed as a pretty progress bar.

Inspired from Password Strength validator snippet

Uses Alix Axel algorithm

Installation

  • Install the plugin

    symfony plugin-install http://plugins.symfony-project.com/sfPasswordStrengthPlugin
    
  • Make a symbolic link

    $ cd web
    $ ln -s ../plugins/sfPasswordStrengthPlugin/web sfPasswordStrengthPlugin
    
  • Create an action

    public function executeCalculateStrength()
    {
      $strength = PasswordStrength::calculate(
                    $this->getRequestParameter('password'),
                    $this->getRequestParameter('login')
      );
      return $this->renderText(PasswordStrength::getBar($strength));
    }
    
  • Add a DIV element where the bar will be placed and observe your field (note: you can see that the login is sent too, in order to test if the login is in the password, which is very bad!)

    echo observe_field('password', array(
          'update'   => 'strength',
          'url'      => 'user_account/calculateStrength',
          'with'     => "$('password').serialize() + '&' + $('login').serialize()",
          'script'   => true,
          'frequency'=> 0.5,
    ));
    
  • Insert the style sheet (I hope this step will be automated soon!)

    <?php use_stylesheet('/sfPasswordStrengthPlugin/css/sfPasswordStrengthStyle.css'); ?>
    
  • You should be done.