skn-036 / cms-role-permission-laravel-vue-spa

This repository uses PHP Laravel and Javascript Vue.js frameworks to implement Role Permissions management in CMS. Cookie based SPA authorization feature of Laravel Sanctum package is used to authorize the user inside the content management system. If a logged user has permission to do specific task, the link to visit the task and the page containing the task will be available to the logged user. Otherwise the page will be unavailable to the logged user with 401 unauthorized error even though try to access the route manually. This repo utilizes the SPA feature of Vue.js.
27 stars 15 forks source link
laravel laravel-sanctum laravel-sanctum-cookie laravel-sanctum-spa laravel10 laravel10-crud pinia pinia-vuejs role-permissions sanctum-authentication sanctum-spa sanctum-vue vue vue-resource vue-router vue-suspense vue3 vue3-composition-api vuejs vuex

About This Repository

This repository uses PHP Laravel version 10, Javascript Vue.js version 3 and Tailwind css frameworks to implement Role Permissions management in CMS. Vite is used to compile the frontend assets. Cookie based SPA authorization feature of Laravel Sanctum package is used to authorize the user inside the content management system. Vue router is used to handle the routing and Pinia is used as the frontend store management system. If a logged user has permission to do specific task, the link to visit the task and the page containing the task will be available to the logged user. Otherwise the page will be unavailable to the logged user with 401 unauthorized error even though try to access the route manually. Though some actions are visible on the frontend for better user experience, but it will handled on the backend and shows a error toast with relevant error message as well as permission requirements. This repo utilizes the SPA feature of Vue.js.

Logging In

Following credentials can be used to log in the system

Sl Role Email Address Password
01 Super Admin sadmin@sadmin.com password
02 Admin admin@admin.com password
03 Author author@author.com password
04 Editor editor@editor.com password
05 User user@user.com password
06 User user1@user.com password
07 User user2@user.com password
08 User user3@user.com password
09 User user4@user.com password


Initailly only Super Admin is granted all the permissions. All other role has no permissions. To add permissions to any other role, first log in as super admin, then go to the roles page. Assign necessary permissions to the role. Then come to the users page and update users roles. One user can have multiple roles. Overall user permissions will be the collection of all roles permissions combined. Super admin role is readonly(can not be edited or deleted). This role can not be applied to any other user. If a new permission is created, updated or deleted, it will be automatically applied to super admin.

Installation

First download this repository. Navigate to root of the project and then

    composer install
    npm install

Copy the contents of .env.example to .env file. Fill up the database credentials(DB_DATABASE, DB_USERNAME, DB_PASSWORD) according to your database. At the root of your project run the following commands on terminal sequentially.

    php artisan key:generate
    php artisan migrate
    php artisan db:seed

This will store all the default data into the database. Then compile the assets and run development server by

    npm run dev

Finally initiate your server on a new terminal and enjoy !!!

    php artisan serve