【问题标题】:Auth::attempt returns true, but redirects to other page and returns guestAuth::attempt 返回 true,但重定向到其他页面并返回 guest
【发布时间】:2019-08-20 23:30:01
【问题描述】:

为什么我的Auth::attempt 在刷新或重定向到另一个页面时返回 false?

下面是我的控制器;我正在使用 Laravel 5.8。我使用的是Auth::logingUsingId(),它是一样的;如果刷新或重定向到另一个页面,则返回 false。

Auth::attempt([
    'email' => $request->email,
    'password' => $request->password,
    'activation_status' => '1'
]);

return redirect('/user');

【问题讨论】:

  • 如果你使用多重保护,那么Auth::guard('admin')->attempt...或者你可以在重定向URL上放置一个Auth::check()

标签: laravel authentication laravel-authentication


【解决方案1】:

我今天正在做同样的事情......我自己的登录和注册路线......我必须在 attemp 方法之后添加$request->session()->regenerate();。希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 2015-03-03
    • 2014-01-17
    • 2016-06-08
    • 1970-01-01
    • 2014-11-22
    • 2017-05-11
    • 2019-04-21
    • 2015-12-14
    • 2019-05-24
    相关资源
    最近更新 更多