Search code examples
vuejs3laravel-9inertiajslaravel-jetstream

How can I authorize (auth login) a user after registering in Jetstream?


Laravel 9, Jetstream, Inertia, Vue3.

After registering, my user is not authenticated. The system successfully registers (creates a user), but does not log him in. How can I authenticate a user automatically after registering in Jetstream? I have a Jetstream component CreateNewUser, but I don't know what to write and where to make it work.


Solution

  • Add this code to CreateNewUser class

    $auth = Auth::attempt([
        'email' => $input['email'],
        'password' => $input['password']
    ]);
    
    if ($auth) {
        session()->regenerate();
    }