Before minus this question, or report a duplicate, please read it completely.
I use a default Laravel Autentification. But for some reason, it's somehow broke down. When I try to login or register, if auth is success it redirects try to redirects me to a correct link, but but at the same time returns me to /login.
Example with dump
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');
}
-
My middleware:
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:clearandconfig:clean - Disable my middleware or auth midlleware in controllers constructor
- Disable all middleware in contructor led to this
- Solutions in question duplicates, or in other forums
If there is not enough information in the question, you can download my entire project on GitHub: https://github.com/Vladislav2018/last.chance/
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire