Laravel 5.4-注册后禁用自动登录 [英] Laravel 5.4 - Disable auto login after registration

查看:148
本文介绍了Laravel 5.4-注册后禁用自动登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

laravel 5.4应用程序中注册用户后,我需要禁用自动登录.有足够的来源[示例] 5.2和5.3版本,但很难找到5.4版本的解决方案.

I need to disable auto login after register an user in laravel 5.4 application. There are enough sources [example] for 5.2 and 5.3 version but it is hard find out a solution for 5.4 version.

在Laravel 5.4中,没有AuthController,因为它分为LoginControllerRegisterController.指导我在laravel 5.4中禁用自动登录.

In Laravel 5.4 there is no AuthController as it divided to LoginController and RegisterController. Guide me to disable auto login in laravel 5.4.

推荐答案

由于您的RegisterController使用RegistersUsers特征,因此所有特征的方法均可用于RegisterController.为了防止用户成功注册后登录,您需要重写的方法是register().这是该方法的初始正文:

Since your RegisterController uses RegistersUsers trait, all of the trait's methods are available to RegisterController. The method you need to override, in order to prevent users to be logged in after they successfully registered is register(). Here's the initial body of the method:

public function register(Request $request)
{
    $this->validator($request->all())->validate();

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

    $this->guard()->login($user);

    return $this->registered($request, $user)
                    ?: redirect($this->redirectPath());
}

该行:$this->guard()->login($user);是用户登录的地方.您可以删除它或对其进行修改以适合您的需求.

The line: $this->guard()->login($user); is where the user gets logged in. You can either remove it or modify it to suit your needs.

这篇关于Laravel 5.4-注册后禁用自动登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆