From 439d86cc5220b692d71313016d6cb84e920fc390 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 09 Oct 2016 15:49:19 +0100 Subject: [PATCH] Use a custom facade rather than overwriting Laravel's hasher --- src/Facades/WPHash.php | 23 +++++++++++++++++++++++ src/Hashing/HashServiceProvider.php | 9 ++++++--- src/Hashing/WordpressHasher.php | 6 ++---- src/Providers/KoseligServiceProvider.php | 4 ++++ 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/Facades/WPHash.php b/src/Facades/WPHash.php new file mode 100644 index 0000000..80ab20d 100644 --- /dev/null +++ a/src/Facades/WPHash.php @@ -1,0 +1,23 @@ + + */ +class WPHash extends Facade +{ + /** + * Get the registered name of the component. + * + * @return string + */ + protected static function getFacadeAccessor() + { + return 'wphash'; + } +} diff --git a/src/Hashing/HashServiceProvider.php b/src/Hashing/HashServiceProvider.php index 3619c1d..5ff0565 100644 --- a/src/Hashing/HashServiceProvider.php +++ a/src/Hashing/HashServiceProvider.php @@ -1,10 +1,11 @@ */ @@ -24,8 +25,8 @@ */ public function register() { - $this->app->singleton('hash', function () { - return new WordpressHasher; + $this->app->singleton('wphash', function () { + return new WordpressHasher(); }); } @@ -36,6 +37,6 @@ */ public function provides() { - return ['hash']; + return ['wphash']; } } diff --git a/src/Hashing/WordpressHasher.php b/src/Hashing/WordpressHasher.php index 4a35120..250e70d 100644 --- a/src/Hashing/WordpressHasher.php +++ a/src/Hashing/WordpressHasher.php @@ -22,8 +22,6 @@ */ public function make($value, array $options = []) { - dd(wp_hash_password($value)); - return wp_hash_password($value); } @@ -49,7 +47,7 @@ */ public function needsRehash($hashedValue, array $options = []) { - return false; + // if the hashed value is md5 it needs rehashing. + return strlen($hashedValue) <= 32; } } - diff --git a/src/Providers/KoseligServiceProvider.php b/src/Providers/KoseligServiceProvider.php index 6136645..9a518e7 100644 --- a/src/Providers/KoseligServiceProvider.php +++ a/src/Providers/KoseligServiceProvider.php @@ -1,8 +1,9 @@ app->register(AuthServiceProvider::class); + + // Hashing service provider + $this->app->register(HashServiceProvider::class); } } -- rgit 0.1.5