Php 如何在Laravel 5.2中进行身份验证后重定向到不同的页面
问题如下。 我做了标准认证。php artisan make:auth。 现在我想在登录和注册后重定向到不同的页面。 web中有两种解决方案。使用postLogin和postRegister方法的重写,但它对我不起作用Php 如何在Laravel 5.2中进行身份验证后重定向到不同的页面,php,authentication,laravel-5.2,Php,Authentication,Laravel 5.2,问题如下。 我做了标准认证。php artisan make:auth。 现在我想在登录和注册后重定向到不同的页面。 web中有两种解决方案。使用postLogin和postRegister方法的重写,但它对我不起作用 class AuthController extends Controller { use AuthenticatesAndRegistersUsers, ThrottlesLogins; public function postLogin(Request $r
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
public function postLogin(Request $request)
{
return property_exists($this, 'redirectTo') ? $this->redirectTo : '/main';
}
public function postRegister(Request $request)
{
return property_exists($this, 'redirectTo') ? $this->redirectTo : '/registrationconfirmation';
}
无论如何,注册和登录后,它会转到同一个页面。
非常感谢您的回答。尝试更改
/app/Http/Controllers/Auth/AuthController.php:
您必须在控制器中覆盖它。检查auth属性中的当前属性
protected $redirectTo = '/your_page';
是的,有这样的变量。但它会在登录和注册后将您重定向到同一个“/your\u页面”,我需要在登录后重定向到“/one\u页面”,并在注册后重定向到“/second\u页面”。