У меня есть серверное приложение на Laravel 9 и еще одно интерфейсное приложение на React.
В серверном приложении создано несколько ролей пользователей и разрешений, и для каждого маршрут в файле маршруты/api.php добавляется промежуточное программное обеспечение для указания разрешения.
Примечание. Разрешению можно назначить несколько ролей.
Пример:
Код: Выделить всё
Route::get('countries', [CountriesController::class, 'index'])->middleware( ['permission:view-countries']);Front-end application has buttons or links and requests to Laravel are made when clicking on them. I need to know if logged in user on front-end have access to those requests before making the requests in order to show or not the buttons or links. I'm thinking to send a list of routes to the front-end, after log in, which are available for that user. Maybe another solution?
Источник: https://stackoverflow.com/questions/754 ... are-allowe
Мобильная версия