[英]Authentication Route Problem Laravel Only on Ubuntu
我在 Windows 和 Ubuntu 上运行一个 Laravel 项目。在 Ubuntu 上,身份验证不起作用。 当我输入正确的用户名和密码时,我被定向到home
(名称为login
的路由)。 但是在Windows上可以正常运行,指向dashboard
页面。
登录控制器.php
class LoginController extends Controller
{
public function index(){
return view('login');
}
public function authenticate(Request $request)
{
$credentials = $request->validate([
'username' => 'required',
'password' => 'required',
]);
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
return redirect()->intended('/dashboard');
}
return back()->withErrors([
'username' => 'The provided credentials do not match our records.',
'password' => 'The provided credentials do not match our records.',
]);
}
}
web.php
Route::get('/home', function () {
return view('home');
})->name('login');
Route::get('/login', [LoginController::class, 'index'])->middleware('guest');
Route::post('/login', [LoginController::class, 'authenticate']);
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard')->middleware('auth');
在 Windows 中,我使用 XAMPP (PHP 8.2.1) 和 Laravel 9.42。 在 Ubuntu 中我使用 PHP 8.1.7 和 Laravel 9.42 而没有 XAMPP。如何在 Ubuntu 上解决这个问题?
https://laravel.com/docs/9.x/authentication#authenticating-users
我认为存在任何缓存问题,只需运行以下命令并检查它。
Php artisan config:cache
Php artisan cache:clear
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.