Maison > Questions et réponses > le corps du texte
La vérification de connexion auth n'utilise plus MD5. Comment ajouter une vérification MD5 sans modifier le code source. Veuillez donner une introduction détaillée.
天蓬老师2017-05-16 16:57:43
La personne qui pose la question parle-t-elle de mots de passe cryptés ?
Si c'est le cas, vous pouvez l'ajouter à User.php
User.php
加上这个
public function setPasswordAttribute($password)
{
$this->attributes['password'] = md5($password);
}
===============================================================
修改部分:
app/
下创建一个MD5/
文件夹。里面创建一个MD5Hasher类(MD5Hasher.php)
:class MD5Hasher implements Illuminate/Contracts/Hashing/Hasher {
/**
* Hash the given value.
*
* @param string $value
* @return array $options
* @return string
*/
public function make($value, array $options = []) {
return md5($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 = []) {
return $this->make($value) === $hashedValue;
}
/**
* Check if the given hash has been hashed using the given options.
*
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function needsRehash($hashedValue, array $options = []) {
return false;
}
}
命令行:
php artisan make:provider MD5HashServiceProvider
在这个文件的register()
方法写上:
public function register()
{
$this->app['hash'] = $this->app->share(function () {
return new MD5Hasher();
});
}
config/app.php
Illuminate\Hashing\HashServiceProvider::class,
================================================= === ==============Partie modifiée :
MD5/
sous app/
. Créez une classe MD5Hasher (MD5Hasher.php)
:MD5HashServiceProvider::class
register()
de ce fichier : 🎜
rrreee
config/app.php
, commentez la ligne suivante : 🎜
rrreee
🎜Ajoutez le vôtre : 🎜
rrreee
🎜🎜Joyeux hacking🎜🎜