简体   繁体   English

Laravel Spark在注册时重定向

[英]Laravel Spark redirect on registration

I am simply trying to redirect a user to a page when they register. 我只是试图在用户注册时将用户重定向到页面。 I have accomplished this redirect when the user logs in by altering the following line in the LoginController in vendors/laravel/Spark/src/Http/Controllers/Auth 当用户登录时,我通过更改vendor / laravel / Spark / src / Http / Controllers / Auth中的LoginController中的以下行来完成此重定向

protected $redirectTo = '/Profile/';

In attempting to do the same thing for the registration, I altered the same line in the RegisterController at the same address. 在尝试对注册执行相同的操作时,我在RegisterController中的相同地址处更改了同一行。 However, that did not work. 但是,那没有用。

I traced the code down to the RedirectsUsers trait which first looks for the redirectPath property and then for the redirectTo property. 我将代码追溯到RedirectsUsers特征,该特征首先查找redirectPath属性,然后寻找redirectTo属性。 So it seems like this should work. 因此,这似乎应该工作。

However, I get redirected to 'undefined' which would seem to indicate that the 'redirectTo' variable is either protected somewhere that it should not be or is simply missing. 但是,我被重定向到“未定义”,这似乎表明“ redirectTo”变量在不应该存在的地方受到保护或者只是丢失了。 The variable is present in the authController for laravel. 该变量存在于laravel的authController中。

如果要在登录或注册新用户后更改重定向,请在App / Providers / SparkServiceProvider.php中的booted()函数中添加以下行

Spark::afterLoginRedirectTo('example');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM