Php Laravel 5.6:Auth::check()在成功的Auth::login之后直接失败
我使用的是Laravel的5.6版 我尝试手动编写一个登录控制器,成功后,它将引导到仪表板,失败后,返回到登录 问题是,当我尝试登录MainController时,所有方式都会重定向回登录。因此,我通过检查Auth::check在登录后是否工作来检查用户是否正确登录了LoginController,并发现它失败了,这使得用户似乎出于某种原因没有正确登录,即使我没有收到任何错误消息 我搜索了几个小时,尝试了很多方法来解决这个问题,但没有成功。所以我希望有人能给我一个如何解决这个问题的指针 我的设置如下所示: web.phpPhp Laravel 5.6:Auth::check()在成功的Auth::login之后直接失败,php,laravel,laravel-5,Php,Laravel,Laravel 5,我使用的是Laravel的5.6版 我尝试手动编写一个登录控制器,成功后,它将引导到仪表板,失败后,返回到登录 问题是,当我尝试登录MainController时,所有方式都会重定向回登录。因此,我通过检查Auth::check在登录后是否工作来检查用户是否正确登录了LoginController,并发现它失败了,这使得用户似乎出于某种原因没有正确登录,即使我没有收到任何错误消息 我搜索了几个小时,尝试了很多方法来解决这个问题,但没有成功。所以我希望有人能给我一个如何解决这个问题的指针 我的设置
<?php
Route::get('/', 'MainController')->name('dashboard');
Route::get('/login', 'LoginController')->name('login');
Route::post('/login/authenticate', 'LoginController@authenticate')->name('authenticate');
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;
class MainController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function __invoke()
{
return view('maintenance');
}
}
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $primaryKey = 'account_id';
protected $table = 'login';
public $timestamps = false;
}
试着像那样使用
public function store()
{
$credentials = array('user_displayname'=>Input::get('user_displayname'),
'user_password'=> Input::get('user_password'));
if (Auth::attempt($credentials))
{
return Auth::user();
}
return 'not logged';
}
试着这样使用
public function store()
{
$credentials = array('user_displayname'=>Input::get('user_displayname'),
'user_password'=> Input::get('user_password'));
if (Auth::attempt($credentials))
{
return Auth::user();
}
return 'not logged';
}
当Auth::check()
返回true时,用户已登录。
因此,在代码中使用其他方法。例如:
if (!Auth::check()) {
dd('Auth::check() failed');
}
当Auth::check()
返回true时,用户已登录。
因此,在代码中使用其他方法。例如:
if (!Auth::check()) {
dd('Auth::check() failed');
}
您可以尝试以下代码:
if (Hash::check('plain-text', $hashedPassword)) {
// The passwords match...
}
您可以尝试以下代码:
if (Hash::check('plain-text', $hashedPassword)) {
// The passwords match...
}
如果(Auth::check()){dd('Auth::check()失败');}这不应该是另一种情况吗?如果Auth::check()返回true,则您将被记录到god spot@matit。应该只是作为问题的答案。如果(Auth::check()){dd('Auth::check()失败);}这不应该是另一种情况吗?如果Auth::check()返回true,则您将被记录到god spot@matit。应该只是作为问题的答案。问题是我需要使用login,因为我必须使用一个不散列密码的表,我现在无法更改它,并且尝试假设数据库中的密码是散列的。问题是我需要使用login,因为我必须使用一个不散列密码的表,而且我现在不能更改它,所以我尝试假设数据库中的密码是散列的。