I have created a helper with a proper function to hash the password (named CustomHash) and it registers well but does not log in, following a tutorial of similar questions I did the following:
Create a folder libraries = > App \ libraries which contains 2 files:
- CustomHasher.php
- CustomHashServiceProvider.php
the CustomHasher.php file looks like this:
<?php
namespace Libraries;
class CustomHasher implements Illuminat\Contracts\Hashing\Hasher {
/**
* Hash the given value.
*
* @param string $value
* @return array $options
* @return string
*/
public function make($value, array $options = array()) {
return hash('customHash', $value);
}
/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function check($value, $hashedValue, array $options = array()) {
return $this->make($value) === $hashedValue;
}
/**
* Check if the given hash has been using the given options.
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function needsRehash($hashedValue, array $options = array()) {
return false;
}
}
The CustomHashServiceProvider.php file looks like this:
<?php
namespace Libraries;
use Libraries\SHAHasher;
use Illuminate\Hashing\HashServiceProvider;
class SHAHashServiceProvider extends Illuminate\Support\ServiceProvider {
/**
* Register the service provider.
*
* @return void
*/
public function register() {
$this->app['hash'] = $this->app->share(function () {
return new CustomHasher();
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides() {
return array('hash');
}
}
my app / helpers.php
<?php
function customHash($value) {
$value = strtoupper(
sha1(
sha1($value, true)
)
);
$value = '*' . $value;
return $value;
}
modify the composer.json to load my libraries
"autoload": {
"classmap": [
// ...
"app/libraries"
]
},
then in App \ config \ app.php Providers comment:
//'Illuminate\Hashing\HashServiceProvider',
and I put below:
'CustomHashServiceProvider',
Then I ran on console
composer dump-autoload
and it throws me the following error:
FatalThrowableError in ProviderRepository.php line 146:
Class 'CustomHashServiceProvider' not found
What am I missing or what am I doing wrong?