我在RedirectifAuthenticated中间件中有以下内容:
import React from 'react';
import ReactDOM from 'react-dom';
import React3 from 'react-three-renderer';
import TrackballControls from './TrackballControls';
import * as THREE from 'three';
import * as OBJLoader from 'three-obj-loader';
OBJLoader(THREE);
class MyClass extends React.Component {
...
render() {
...
const objLoader = new THREE.OBJLoader();
}
}
但是当用户登录时,这会重定向到我重命名为/ dashboard的/ home。
我已将路线,视图等从主页更改为仪表板。
我在整个项目中都进行了搜索,但是我找不到到/ home的路线或者提到不是标题的家或者在无关的文件中,例如yarn.lock文件。
我在这个问题上发现了很多文章,但我没有Authenticate.php,我没有旧的Auth中间件。
编辑:以下是我的登录控制器和路线:
的LoginController:
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('dashboard');
}
return $next($request);
}
路线:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
//protected $redirectTo = '/dashboard';
public function authenticated(Request $request)
{
// Logic that determines where to send the user
if($request->user()->hasRole('Stallhollder')){
return redirect('/dashboard');
}
if($request->user()->hasRole('Manager')){
return redirect('/dashboard2');
}
}
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
答案 0 :(得分:2)
The default Laravel login controller将$redirectTo
的值设置为&#39; / home&#39;。您需要将其更新到新路由,因为它定义了登录后重定向到的位置。
答案 1 :(得分:0)
在
Run
php artisan make:auth
之后您拥有以下控制器。
现在,在控制器文件更改中重定向到
dashboard
示例:
protected $redirectTo = '/dashboard';
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected function authenticated(Request $request)
{
// Logic that determines where to send the user
if($request->user()->hasRole('Stallhollder')){
return redirect('/dashboard');
}
if($request->user()->hasRole('Manager')){
return redirect('/dashboard2');
}
public function __construct(){
$this->middleware('guest')->except('logout');
}
}
<?php
Auth::routes(); // First Line Is `Auth::routes();`
Route::get('/dashboard', 'DashboardController@index');
Route::resource('/bookings', 'BookingsController');
Route::get('/dashboard2', function () {
return view('dashboard2');
});
?>
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/dashboard');
}
return $next($request);
}