Jump to content

Creating module to handle password validation


Recommended Posts

HI, I'm looking to implement some rules for password creation and I imagine I'll need to create a module for this. One thing I'd like to do is block the 10,000 most common passwords (From this article) by checking the entered password against the file containing the list.

Are there any methods of hooking into the password reset page (or potentially any password entry pages I need to create) to validate against the list or will this require more than a module to accomplish?

EDIT: Title is misleading, it should have been password validation rather than password entry. Apologies.

  • Like 6
Link to comment
Share on other sites

As a basic test case, you could add this to your /site/templates/admin.php

wire()->addHookAfter('InputfieldPassword::processInput', function($event) {
  $inputfield = $event->object;
  $password = $inputfield->attr('value'); 
  $bad = array('test', 'abc', '123', 'password', 'unicorn'); 
  if(in_array($password, $bad)) {
    $inputfield->error("That's not good enough of a password, try again"); 
    $inputfield->attr('value', ''); 
  }
}); 
  • Like 5
Link to comment
Share on other sites

Cool. I'll give this a go and see how I get on. I'd like to move this into a module at some point to allow easybuse by others but I'll work on getting it working before I think about that part 9f my plan.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...