php - 在 Laravel 5.3 中注册后禁用自动登录

标签 php laravel

谁能帮帮我。在 laravel 5.3 中注册后如何禁用自动登录。 我可以在 5.2 中完成,但在 5.3 中不行。

最佳答案

5.3 中,您只需重写 register 方法。您可以将以下内容添加到您的 App\Http\Controllers\Auth\RegisterController:

/**
 * Handle a registration request for the application.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function register(Request $request)
{
    $this->validator($request->all())->validate();

    event(new Registered($user = $this->create($request->all())));

    //The auto login code has been removed from here.

    return redirect($this->redirectPath());
}

此外,您可以在 register 方法本身中更改重定向路径,或者仅将 $redirectTo 属性更新到类的顶部。

希望这对您有所帮助!

关于php - 在 Laravel 5.3 中注册后禁用自动登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41408162/

相关文章:

php - Symfony 4 - 找不到所有迁移版本

php - 使用 jquery 在 session 中存储数据并在 PHP 中访问该值

php - 构造函数默认非可选参数初始化对象?

php - Laravel 设置和获取 UTC 时间

php - 用户应该成为 Laravel 中的资源吗?

php - 在 bit.ly API 中使用 oauth 访问 token 和登录/apikey 之间的区别

PHP 脚本创建一个空的 SQL 文件

javascript - 禁用 Bootstrap 日期时间选择器中的 future 日期

css - 在 <form action> 中使用 CSS

php - Laravel 5.5 Cron Job proc_open 和 ArgvInput 问题