Laravel - Not log in after registration....?

Asked

Viewed 559 times

2

How to remove automatic login after registering?

I commented the following line from the Registerusers file:

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

        if ($validator->fails()) {
            $this->throwValidationException(
                $request, $validator
            );
        }
        //Linha comentada
        //Auth::guard($this->getGuard())->login($this->create($request->all()));

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

This prevented logging in but tbm does not register the user.

I tried to let you create:

Auth::guard($this->getGuard())->create($request->all());

However, it gives the error: 'Call to Undefined method Illuminate Auth Sessionguard::create()'.

What I do?

  • The method create is part of your controller, not class Auth.

1 answer

3


It would be easier for you to take the model that is responsible for authentication and use the method create.

But I can say that, in Laravel, the method responsible for the login is the Auth::login(), which is called at the end of its commented line.

In your case, the code that needs to be left to just create the user is just the $this->create().

Behold:

$this->create($request->all())

Browser other questions tagged

You are not signed in. Login or sign up in order to post.