Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Logowanie w Laravelu
trifek
post 5.05.2020, 13:06:29
Post #1





Grupa: Zarejestrowani
Postów: 340
Pomógł: 0
Dołączył: 28.09.2015

Ostrzeżenie: (0%)
-----


Witam serdecznie,
Mam projekt w Laravelu 6 i mam taką migrację:

  1. Schema::create('users', function (Blueprint $table) {
  2. $table->id();
  3. $table->string('name');
  4. $table->string('email')->unique();
  5. $table->timestamp('email_verified_at')->nullable();
  6. $table->string('password');
  7. $table->char('enable', 1)->default(0);
  8. $table->rememberToken();
  9. $table->timestamps();
  10. });


Używam standardowego systemu logowania w Laravelu.
Chciałbym dodatkowo sprawdzać przy logowaniu parametr enable = 1.

W jaki sposób można to zrobić?
Go to the top of the page
+Quote Post
viking
post 5.05.2020, 13:14:16
Post #2





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Możesz to dodać do LoginController::credentials


--------------------
Go to the top of the page
+Quote Post
trifek
post 5.05.2020, 13:17:58
Post #3





Grupa: Zarejestrowani
Postów: 340
Pomógł: 0
Dołączył: 28.09.2015

Ostrzeżenie: (0%)
-----


Próbuję coś takiego:

  1. protected function credentials(Request $request)
  2. {
  3. return array_merge($request->only($this->username(), 'password'), ['enable' => 1]);
  4. }


ale zwraca mi:

Argument 1 passed to App\Http\Controllers\Admin\Auth\LoginController::credentials() must be an instance of App\Http\Controllers\Admin\Auth\Request, instance of Illuminate\Http\Request given, called in /var/www/vendor/laravel/ui/auth-backend/AuthenticatesUsers.php on line 83

Wiesz może dlaczego?
Go to the top of the page
+Quote Post
viking
post 5.05.2020, 13:26:37
Post #4





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Bo nie zaimportowałeś w pliku Illuminate\Http\Request?


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.03.2024 - 02:34