2016-12-01 31 views
0

WordpressからLaravelにユーザーをインポートしようとしていますが、パスワードを正しく取得できません。ユーザーがログインすると、md5に対してパスワードをチェックし、正しい場合はbcryptでハッシュする必要があります。WordpressのパスワードをLaravelに転送

私はAuthenticatesUsers.phpログイン()私もMigrating old md5 passwords to bcrypt with Laravel 5.2's built in authで試してみた

//If user got here it means the AUTH was unsuccessful 
//Try to log them IN using MD5 
if($user = User::where('email', $credentials['email'])->where('password', md5($credentials['password']))->first()){ 
    //It this condition is true, the user had the right password. 

    //encrypt the password using bcrypt 
    $user->password = Hash::make($credentials['password']); 
    $user->save(); 

    if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) { 
     return $this->handleUserWasAuthenticated($request, $throttles); 
    } 

    return $this->handleUserWasAuthenticated($request, $throttles); 

} 

でこれを試してみたが、私はそれがMD5パスワードを検証するために取得することはできません。

+0

'$ユーザー=ユーザー::(...'それがユーザーを見つけないで何が起こる –

+0

はい、それはユーザーを見つけるが、 – mattesj

+0

ユーザーが見つかった場合、md5パスワードはすでに検証されていますが、できないことはパスワードをbcryptにハッシュした後にユーザーを認証することです。 –

答えて

0

使用mikemclin/laravel-wp-password/hでパスワードを確認したします?

$password = 'plain-text-password'; 

$wp_hashed_password = '$P$B7TRc6vrwCfjgKLZLgmN.dmPo6msZR.'; 

if (WpPassword::check($password, $wp_hashed_password)) { 
    // Password success! 
} else { 
    // Password failed :(
} 
関連する問題