Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config/password-policy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Password Policy Settings
|--------------------------------------------------------------------------
|
| Configure the rule name used when validating a password.
|
*/

'rule' => 'password',

];
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class PasswordPolicyServiceProvider extends ServiceProvider
*/
public function register()
{
$configPath = __DIR__ . '/../../../../config/password-policy.php';
$this->mergeConfigFrom($configPath, 'password-policy');

$this->registerManager();
$this->registerBuilder();
$this->registerFacade();
Expand All @@ -33,6 +36,9 @@ public function register()
*/
public function boot()
{
$configPath = __DIR__ . '/../../../../config/password-policy.php';
$this->publishes([$configPath => $this->getConfigPath()], 'config');

$this->configureValidationRule();
}

Expand Down Expand Up @@ -63,7 +69,7 @@ protected function registerBuilder()
*/
protected function configureValidationRule()
{
$this->app['validator']->extend('password', PasswordValidator::class . '@validate');
$this->app['validator']->extend($this->app['config']->get('password-policy.rule'), PasswordValidator::class . '@validate');
}

/**
Expand Down Expand Up @@ -104,4 +110,14 @@ protected function defaultPolicy(PolicyBuilder $builder)
{
return $builder->getPolicy();
}

/**
* Get the config path
*
* @return string
*/
protected function getConfigPath()
{
return config_path('password-policy.php');
}
}