A Rails API application implementing role-based access control with JWT authentication.
Supports Super Admin, Admin, and Normal User roles with CRUD operations according to permissions.
- Authentication using Devise + JWT
- Role-based authorization
- Super Admin can manage Admins & Users
- Admin can manage Normal Users
- Normal User can manage their own profile
- Profile management with optional profile photo upload
- Seeded default roles and Super Admin user
| Role | Permissions |
|---|---|
| Super Admin | Full CRUD on Admins and Users |
| Admin | CRUD on Normal Users |
| Normal User | View & update own profile |
POST /users/sign_in→ LoginPOST /users→ Register (Normal User by default)DELETE /users/sign_out→ Logout
GET /admins→ List all adminsPOST /admins→ Create adminPUT /admins/:id→ Update adminDELETE /admins/:id→ Delete admin
GET /users→ List usersPOST /users→ Create userPUT /users/:id→ Update userDELETE /users/:id→ Delete user
GET /profile→ Get own profilePUT /profile→ Update own profile
- Clone the repo
git clone https://github.com/ramitgupta195/role_based_system.git cd role_based_system - Install dependencies
bundle install rails db:create db:migrate db:seed
- Run the Server
rails s
- Use Post or curl to test endpoints
-Authentication uses JWT, so you need to include the Authorization: Bearer header for protected endpoints.
- Default Super Admin credentials (from seeds):
- Email:
superadmin@example.com - Password:
password123
- Email: