Промежуточное программное обеспечение аутентификации Laravel Auth::check() возвращает false ⇐ Php
Промежуточное программное обеспечение аутентификации Laravel Auth::check() возвращает false
I try to implement ldap user authentication using the ldaprecord package with Laravel 8. Although user authentication is successful, I cannot access the session when I check it through the middleware.
After Auth::login($user), Auth::check() method returns true, somehow on Auth Middleware it return false. I use file for session_driver. The file is created at storage/framework/sessions successfully, so permissions look okay to me. What should I pay attention to for the session to be permanent?
AuthController.php
class AuthController extends Controller { public function getLogin(){ return view('login'); } public function postLoginForm(Request $request){ $request->validate([ 'username' => 'required', 'password' => 'required', ]); $username = $request->username . "@iegm.local"; $connection = Container::getConnection('default'); if ($connection->auth()->attempt($username, $request->password)) { $user = User::firstOrCreate(['username' => $request->username], [ 'is_admin' => 0, 'is_active' => 1 ]); Auth::login($user); dd(Auth::check()); // --> return true return redirect()->route('get.anasayfa'); } return back()->with('fail', 'basarisiz'); } public function logout() { Session::flush(); Auth::logout(); return redirect('login'); } } auth.php
Источник: https://stackoverflow.com/questions/781 ... turn-false
I try to implement ldap user authentication using the ldaprecord package with Laravel 8. Although user authentication is successful, I cannot access the session when I check it through the middleware.
After Auth::login($user), Auth::check() method returns true, somehow on Auth Middleware it return false. I use file for session_driver. The file is created at storage/framework/sessions successfully, so permissions look okay to me. What should I pay attention to for the session to be permanent?
AuthController.php
class AuthController extends Controller { public function getLogin(){ return view('login'); } public function postLoginForm(Request $request){ $request->validate([ 'username' => 'required', 'password' => 'required', ]); $username = $request->username . "@iegm.local"; $connection = Container::getConnection('default'); if ($connection->auth()->attempt($username, $request->password)) { $user = User::firstOrCreate(['username' => $request->username], [ 'is_admin' => 0, 'is_active' => 1 ]); Auth::login($user); dd(Auth::check()); // --> return true return redirect()->route('get.anasayfa'); } return back()->with('fail', 'basarisiz'); } public function logout() { Session::flush(); Auth::logout(); return redirect('login'); } } auth.php
Источник: https://stackoverflow.com/questions/781 ... turn-false
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Auth::check() и Auth::attempt() возвращают false на сервере для определенной таблицы
Anonymous » » в форуме Php - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Добавить AUTH в FASTAPI через промежуточное программное обеспечение и включить в OpenAPI
Anonymous » » в форуме Python - 0 Ответы
- 5 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Добавить AUTH в FASTAPI через промежуточное программное обеспечение и включить в OpenAPI
Anonymous » » в форуме Python - 0 Ответы
- 7 Просмотры
-
Последнее сообщение Anonymous
-