前提
・Laravel9を利用。
・また、ログインする際はanswersテーブルに登録してあるアドレスとユーザーの名前で入力する。(仕様書にパスワードを利用すると書いていないなく、同時にuserテーブルは作成しない為)
・Laravel Breezeのパッケージを利用し、ログイン機能のみを利用する。
・ルーティングとしては/systemルートにてログインを行い、成功したら/system/indexパスへと遷移するようにする。
ここに質問の内容を詳しく書いてください。
Breezeのパッケージをカスタマイズしているのですが、ログイン時に参照するDBを(users→answersテーブルに)変更し、ログインが出来るようにしたいです。どうすればよろしいでしょうか?
実現したいこと
パッケージに元から備わっているUsersテーブルでなく、自作したAnswersテーブルを参照し、レコードに登録されている名前とアドレスでログインを行う。
発生している問題・エラーメッセージ
上記の状態でログインをしようとするとArgument #2($provider) must be of type Illuminate\Contracts\Auth\UseProvider, null given, callled in...
というエラーが出現し、トップページすら上記のエラーでスタックしてしまっている。
該当のソースコード
以下認証する関数のコードになります。
public function authenticate()
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([ 'email' => __('auth.failed'), ]); } RateLimiter::clear($this->throttleKey()); } /** * Ensure the login request is not rate limited. * * @return void * * @throws \Illuminate\Validation\ValidationException */ public function ensureIsNotRateLimited() { if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return; } event(new Lockout($this)); $seconds = RateLimiter::availableIn($this->throttleKey()); throw ValidationException::withMessages([ 'email' => trans('auth.throttle', [ 'seconds' => $seconds, 'minutes' => ceil($seconds / 60), ]), ]); } /** * Get the rate limiting throttle key for the request. * * @return string */ public function throttleKey() { return Str::lower($this->input('email')).'|'.$this->ip(); }
試したこと
・https://zakkuri.life/laravel-auth-by-other-table のサイトを参考にconfig/auth.phpファイルを修正した。
・各種ルーティングの修正を行う。
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
単純なログイン機能であるので、このようなパッケージを使わず自作のログイン方法でもっと簡単な方法があれば、教えていただきたいです。
0 コメント