Skip to content

Learning path document view triggers Vue error when securityStore.user is null (user.roles / user["@id"]) asking for certificate #8444

@Gastone67

Description

@Gastone67

Environment:

  • Chamilo: 2.0.2 (problem also observed before update)
  • PHP: [8.3]
  • Browser: Firefox
  • Fresh browser session / private window tested
  • Cache cleared, Service Worker removed
  • Problem persists after upgrade to 2.0.2

Problem:
Opening a document inside a learning path causes the page to never finish loading. Browser console shows Vue runtime errors.

Observed errors:

TypeError: can't access property "roles", n.user is null

and after investigation:

TypeError: can't access property "@id", n.user is null

Stack traces involve:

/build/vue.[hash].js
/build/legacy_document.[hash].js

Reproduction steps:

  1. Log in as user
  2. Open a course
  3. Open a learning path
  4. Open a document item inside the learning path
  5. Browser stays loading indefinitely
  6. Vue errors appear in console

Findings:
/check-session returns HTTP 200.

Database integrity checks did not reveal missing users:

  • session_rel_user OK
  • session_rel_course_rel_user OK
  • resource/user relations OK

The issue appears frontend-related.

Possible problematic code found in:

assets/vue/router/index.js

Example:

securityStore.user.roles.push("ROLE_CURRENT_COURSE_SESSION_TEACHER")
securityStore.user.roles.push("ROLE_CURRENT_COURSE_SESSION_STUDENT")

This code executes without verifying that:

securityStore.user !== null

Other parts of Chamilo already use safe access patterns:

securityStore.user?.roles || []

This suggests a race condition where router initialization runs before securityStore.user is available.

Potential fix:
Guard access to securityStore.user before reading roles or ["@id"].

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions