refact: public access get roles

This commit is contained in:
pahmiudahgede 2025-03-07 23:20:38 +07:00
parent 2072d047d4
commit 7d2a02c65f
1 changed files with 8 additions and 8 deletions

View File

@ -16,10 +16,10 @@ func NewRoleHandler(roleService services.RoleService) *RoleHandler {
func (h *RoleHandler) GetRoles(c *fiber.Ctx) error {
roleID, ok := c.Locals("roleID").(string)
if !ok || roleID != utils.RoleAdministrator {
return utils.GenericResponse(c, fiber.StatusForbidden, "Forbidden: You don't have permission to access this resource")
}
// roleID, ok := c.Locals("roleID").(string)
// if !ok || roleID != utils.RoleAdministrator {
// return utils.GenericResponse(c, fiber.StatusForbidden, "Forbidden: You don't have permission to access this resource")
// }
roles, err := h.RoleService.GetRoles()
if err != nil {
@ -32,10 +32,10 @@ func (h *RoleHandler) GetRoles(c *fiber.Ctx) error {
func (h *RoleHandler) GetRoleByID(c *fiber.Ctx) error {
roleID := c.Params("role_id")
roleIDFromSession, ok := c.Locals("roleID").(string)
if !ok || roleIDFromSession != utils.RoleAdministrator {
return utils.GenericResponse(c, fiber.StatusForbidden, "Forbidden: You don't have permission to access this resource")
}
// roleIDFromSession, ok := c.Locals("roleID").(string)
// if !ok || roleIDFromSession != utils.RoleAdministrator {
// return utils.GenericResponse(c, fiber.StatusForbidden, "Forbidden: You don't have permission to access this resource")
// }
role, err := h.RoleService.GetRoleByID(roleID)
if err != nil {