Laravel 5.5在登录时更改密码加密 [英] Laravel 5.5 change password encryption on login
本文介绍了Laravel 5.5在登录时更改密码加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改Laravel的默认密码.我想用我自己的. 对于注册,我知道我该怎么做:在RegisterController中,我可以更改bcrypt函数
I want to change the Laravel's default password encyption. I want to use my own. For the registration I know how I can do it: in the RegisterController I can change the bcrypt function
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'username' => $data['username'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
但是在哪里可以更改登录名检查密码是否有效的方式?
But where do I change how the login checks if the password is valid ?
推荐答案
使用 Hash::check
if (Hash::check('secret', $hashedPassword))
{
// The passwords match...
}
或
$userdata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
// attempt to do the login
if (Auth::attempt($userdata)) {
// success
}
可以使用
Can log using
use Illuminate\Support\Facades\Auth;
Auth::login($user); or
Auth::loginUsingId(1, true); # true is remeber me option
这篇关于Laravel 5.5在登录时更改密码加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文