データベースにユーザーのテーブルがあります。それらのパスワードは、私自身のカスタムハッシュ関数で生成されます。
自分のハッシュクラスを使用するためにlaravel4の認証メソッドをオーバーライドするにはどうすればよいですか?
これは私がやろうとしてきたことです:
class CustomUserProvider implements Illuminate\Auth\UserProviderInterface {
public function retrieveByID($identifier)
{
return $this->createModel()->newQuery()->find($identifier);
}
public function retrieveByCredentials(array $credentials)
{
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// Eloquent User "model" that will be utilized by the Guard instances.
$query = $this->createModel()->newQuery();
foreach ($credentials as $key => $value)
{
if ( ! str_contains($key, 'password')) $query->where($key, $value);
}
return $query->first();
}
public function validateCredentials(Illuminate\Auth\UserInterface $user, array $credentials)
{
$plain = $credentials['password'];
return $this->hasher->check($plain, $user->getAuthPassword());
}
}
class CodeIgniter extends Illuminate\Auth\Guard {
}
App::bind('Illuminate\Auth\UserProviderInterface', 'CustomUserProvider');
Auth::extend('codeigniter', function()
{
return new CodeIgniter( App::make('CustomUserProvider'), App::make('session'));
});
Auth ::attemptメソッドを実行すると次のエラーが発生します:ErrorException:警告:G:\ Dropbox \ Workspaces \ www \ video \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation\Applicationのissetまたはemptyの不正なオフセットタイプ.php行352