Перед тем, как поставить минус на этот вопрос или сообщить о дубликате, прочитайте его полностью.
Я использую аутентификацию Laravel по умолчанию. Но по какой-то причине оно как-то сломалось.
Когда я пытаюсь войти или зарегистрироваться, если авторизация успешна, он перенаправляет попытку перенаправить меня на правильную ссылку, но в то же время возвращает меня к /login.
Пример с дампом
Debugbar после попытки авторизации
Source files
1. My routes:
Auth::routes();
Route::get('/confirm', function () {
return view('confirm');
})->name('confirm');
Route::post('/confirm', 'EmployeeController@store')->name('addworker');
Route::get('users/{id}', 'EmployeeController@show')->where('id', '[0-9]+')->name('account');
Route::get('/home', 'HomeController@index')->name('home');
2. Changes into login and register controllers:
protected function redirectTo()
{
return route('account',['id'=> auth()->user()->id]);
}
3.Methods in a EmployeeController, that action in auth:
public function __construct()
{
$this->middleware('auth');
$this->middleware('confirmated');
}
public function show($id)
{
return view('account');
}
4. My middleware:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use App\Employee;
class CheckConfirm
{
public function handle($request, Closure $next)
{
if (Auth::check()) {
$id = Auth::id();
$empl = Employee::where('user_id', '=', $id)->first();
Debugbar::info($empl);
if ($empl == null) {
return redirect()->route('confirm');
} else {
dump($empl);
return $next($request);
}
} else {
return redirect()->route('login');
}
}
}
What did not help me
- clearing the cache and browser history including the artisan commands:
cache:clear
and config:clean
- Disable my middleware or auth midlleware in controllers constructor
- Disable all middleware in contructor led to это
- Решения обсуждаются дубликаты или на других форумах
Если в вопросе недостаточно информации, вы можете скачать весь мой проект на GitHub: https://github.com/Vladislav2018/last.chance/