2

I was developing an app to manage users. I need to access auth/register from logged in users. The default auth redirecting to home page.

It seems after registration, Auth automatically doing ::attempt.

How can I prevent it?

vhu
  • 12,244
  • 11
  • 38
  • 48
  • Could you [show some problematic code](http://stackoverflow.com/help/mcve) [please](http://stackoverflow.com/help/how-to-ask)? – bufh Aug 07 '15 at 19:48
  • here is the [question](http://stackoverflow.com/questions/31478303/how-to-disable-auto-login-on-register-in-laravel-5/36628990#36628990) with accepted answer. – sum Apr 14 '16 at 16:38

1 Answers1

5

Assuming you use the RegistersUsers (or AuthenticatesAndRegistersUsers) trait in your controller you can override the postRegister method and simply not log the user in. You can see the original method here

Without logging it that would be:

public function postRegister(Request $request)
{
    $validator = $this->validator($request->all());
    if ($validator->fails()) {
        $this->throwValidationException(
            $request, $validator
        );
    }
    return redirect($this->redirectPath());
}
lukasgeiter
  • 147,337
  • 26
  • 332
  • 270