Skip to content

Fix: Guard PermissionService context and fix template call - #108

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/permission-service-context
Open

Fix: Guard PermissionService context and fix template call#108
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/permission-service-context

Conversation

@sentry

@sentry sentry Bot commented Aug 9, 2026

Copy link
Copy Markdown

This PR addresses the TypeError: Cannot read properties of undefined (reading 'companyId') occurring in PermissionService.hasPermission.

The root cause was identified as PermissionService attempting to access context.companyId when the context argument was undefined. This happened because company-view.page.html was calling hasPermission('company-stats', 'Company') without providing the necessary context object for company-specific permissions.

The fix involves a two-pronged approach:

  1. Robustness in PermissionService: Added optional chaining (context?.companyId) to line 37 of src/app/providers/permission.service.ts. This ensures that if context is undefined, the expression gracefully evaluates to undefined instead of throwing a TypeError.
  2. Correcting the call site: Modified line 109 of src/app/pages/logged-in/company/company-view/company-view.page.html to correctly pass the companyId context: permissionService.hasPermission('company-stats', 'Company', { companyId: company_id }). This aligns the call with the expected signature of the service method.

Fixes SH-STAFF-APP-6
Fixes TECH-2027

@linear-code

linear-code Bot commented Aug 9, 2026

Copy link
Copy Markdown

TECH-2027

@netlify

netlify Bot commented Aug 9, 2026

Copy link
Copy Markdown

Deploy Preview for studenthub-staff ready!

Name Link
🔨 Latest commit 6d342c3
🔍 Latest deploy log https://app.netlify.com/projects/studenthub-staff/deploys/6a79071960eba400087c89c8
😎 Deploy Preview https://deploy-preview-108--studenthub-staff.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants