Laravel甚至重定向经过身份验证的用户登录

时间:2019-04-20 09:50:22

标签: laravel laravel-5

在减去此问题或报告重复之前,请完整阅读。

我使用默认的Laravel Autentification。但是由于某种原因,它以某种方式崩溃了。 当我尝试登录或注册时,如果auth成功,它将进行重定向,请尝试将我重定向到正确的链接,但同时将我返回到/ login。

转储示例

尝试身份验证后的调试栏

源文件

1。我的路线:

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。更改为登录和注册控制器:

protected function redirectTo()
{
    return route('account',['id'=> auth()->user()->id]);
}

3.EmployeeController中的方法,在auth中执行该操作:

public function __construct()
{
    $this->middleware('auth');
    $this->middleware('confirmated');
}

public function show($id)
{
    return view('account');
}

4。我的中间件:

<?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');
        }
    }
}

没有有什么帮助我

  1. 清除缓存和浏览器历史记录,包括工匠命令:cache:clearconfig:clean
  2. 在控制器构造函数中禁用我的中间件或身份验证中间件
  3. 禁用所有导致this的构造器中的中间件
  4. 问题重复或在其他论坛中的解决方案

如果问题中没有足够的信息,您可以在GitHub上下载我的整个项目:https://github.com/Vladislav2018/last.chance/

0 个答案:

没有答案