loading...

Palanga Street Radio
User Role Implementation

Description

Palanga Street Radio is an independent radio based in Vilnius, Lithuania. I was brought on to implement a system of user roles for their CMS, in order to allow show creators to upload their own shows to the archives, while restricting them from accessing admin pages.

The user role system I set up contains two roles: admin and contributor. While the admin is able to view all pages and perform all actions, the contributor can only view the “shows” page, which lists all shows in the archives, upload shows, and edit shows they’ve uploaded previously.

The implementation of the user roles involved:
  • Adding a “role_id” attribute to the user model, and a corresponding “Role” enum class
  • Updating the "New User" and "Edit User" pages to have a "Role" checkbox, that allows admins to set a user's permissions
  • Creating a new Gate that checks the currently logged in user’s role
  • Adding middleware to admin-only CMS routes which redirect users to the shows page if they don’t have admin permissions
  • Adding middleware to “update” and “delete” show routes which confirms that the user performing the action is either an admin, or is the uploader of the show

Details
  • CLIENT Palanga Street Radio
  • Tools & Frameworks PHP, Laravel, PostgreSQL
Categories: Backend Development