LuiKang
LuiKang

Reputation: 83

How to manage users using REST API at Laravel Jetstream

I'm making an application with Laravel8/Jetstream backend and Vue2 FrontEnd.

I think Jetstream's documentation is not so clear, in opponent to Laravel's documentation and Laracasts by JEFFREY WAY, which are great and usable. But customizing this new Auth feature are less documented IMHO.

I would like to make a frontend page for managing users by admin and a profile manager for every user to edit their own data with password change function - and use a controller to use the Jetstreams' (and Fortify) services.

I didn't found any help or best practice in which way should I go.

Please help me to put me on the right way.

Upvotes: 2

Views: 2658

Answers (1)

LuiKang
LuiKang

Reputation: 83

As Maarteen pointed out, I had to use the routes provided by Jetstream:

To update the current user's profile information with API support turned on, a PUT request must be called to the user/profile-information route.

To change his/her password, a PUT request must be called to the user/password route. Here, the App\Actions\Fortify\UpdateUserPassword action is called, which uses the password validation rules provided by the App\Actions\Fortify\PasswordValidationRules class.

To manage users by an administrator I had to create a new controller with custom actions, but for example, for the new user creation logic I used the CreatesNewUsers class to get the input and it uses the App\Actions\Fortify\CreateNewUserclass, which can be customized.

Upvotes: 3

Related Questions