Skip to content

ActivityLogService.log() blocks OWNER and VET from creating medical records #116

Description

@annikaholmqvist94

Body:

Problem

ActivityLogService.log() calls activityLogPolicy.canCreate(user) before saving
the log entry. Since canCreate() only allows ADMIN, any action triggered by an
OWNER or VET that results in automatic logging (create, update, assignVet,
updateStatus, close) throws ForbiddenException and rolls back the entire
transaction.

Affected flow

POST /api/medical-records → MedicalRecordService.create()
→ activityLogService.log() → activityLogPolicy.canCreate(OWNER) → 403
@transactional rolls back → record is never saved

Root cause

ActivityLogService.log() is an internal system method, always called by the
system automatically — never directly by a user via API. It should never enforce
user-level permissions.

Fix

Remove the activityLogPolicy.canCreate(user) call from ActivityLogService.log()
on line 36.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions