laravel / jetstream

Tailwind scaffolding for the Laravel framework.
https://jetstream.laravel.com
MIT License
3.95k stars 809 forks source link

php artisan jetstream:install livewire did not completely scaffold Auth #102

Closed jimgwhit closed 4 years ago

jimgwhit commented 4 years ago

Description: No Login Controller is created and no trait.

Tried

php artisan jetstream:install livewire

Also tried

php artisan jetstream:install inertia

A HomeController will also be generated to handle post-login requests to your application's dashboard.

Wasn't created. Also no Login controller was created. Where is the login controller?

I also use the authenticated method from the trait, but where is this trait now, no UI any more?

Is the UI still okay with version 8 (and future versions if I don't want jetstream), or is the UI deprecated, do you have to use jetstream. Not anything in docs about the laravel ui for Auth.

And I thought jetstream was optional, where is the AuthenticatesUsers.php trait now located.

The docs are leaving out so much it seems. The docs says there should be controller and trait:

Authenticating

Now that you have routes and views setup for the included authentication controllers, you are ready to register and authenticate new users for your application! You may access your application in a browser since the authentication controllers already contain the logic (via their traits) to authenticate existing users and store new users in the database.

alxmtr commented 4 years ago

Hey jimgwhit,

It seems like no controllers or traits are supposed to be created when installing Jetsteam as it used to be with Laravel UI.

For your concerns about UI being deprecated, the GitHub page of the package says it should no longer be used on new Laravel projects, we have to use Jetstream instead.

Maybe you should give us more details about what you are trying to do with the auth that requires you to use the AuthenticatesUsers trait so we can help you.

jimgwhit commented 4 years ago

@alxmtr v7 the UI had the mentioned trait, how in v8 do I duplicate the methods such as authenticated.

And where in v8 are the authentication traits located? Even the v8 docs state there are controllers and traits, where?

alxmtr commented 4 years ago

Laravel Fortify powers the auth features of Jetstream and is probably what you are looking for.

jimgwhit commented 4 years ago

@alxmtr in vendor folder and saw controllers but what traits is the documentation referring to I saw no traits? Has all control over redirection been removed?

I usually pick a redirect location depending role.

Are there still traits you can override. I just can't seem to find them.

alxmtr commented 4 years ago

Laravel 8 has been released only 10 hours ago as I write this and the documentation is probably still referring to the auth traits and controllers from Laravel UI. It is misleading.

There are no traits like AuthenticatesUsers anymore in Jetstream and Fortify.

jimgwhit commented 4 years ago

I also noticed that there's only one place in config to set where to redirect to once logged in.

However shouldn't there be an option somewhere, that way if an admin, redirect to admin page, if another role, redirect to another page, etc for a few other roles. This was easy in Prior versions, with the authenticated method.

Could you implement something similar in this version.

Not only myself, but I know many other users use this functionality.

I did a temporary work around:

Changed RouteServiceProvider line to

public const HOME = 'redirects';
//or
public const HOME = '/redirects';

Made a route:

Route::get('redirects', 'App\Http\Controllers\HomeController@index');
//or
Route::get('/redirects', 'App\Http\Controllers\HomeController@index');

I don't use forward slash (/) because my htaccess is setup so I can skip it.

And in HomeController it redirects depending on role:

    public function index()
    {
        $role = Auth::user()->role;
        $checkrole = explode(',', $role);
        if (in_array('admin', $checkrole)) {
            return redirect('dog/indexadmin');
        } else {
            return redirect('pet/index');
        }

    }

This part

        $role = Auth::user()->role;
        $checkrole = explode(',', $role);

Adjust to how you get user role.

But hoping for a decent fix in the framework like a trait to use or something.

taylorotwell commented 4 years ago

These out of date docs have been updated.

jimgwhit commented 4 years ago

Also any one landing here, @snapey put a fix on the forum for redirects, see:

https://laracasts.com/discuss/channels/laravel/version-8-redirects I included there a small example. Either will work. Also see his link in the post.