Skip to content

Commit

Permalink
Expose logged-in LMS user basic details to the FE via config (#6376)
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya authored Jun 18, 2024
1 parent 4b4b31c commit e9c3511
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lms/resources/_js_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ def _config(self):
config["debug"]["tags"].append(
"role:instructor" if self._lti_user.is_instructor else "role:learner"
)
config["user"] = {
"display_name": self._lti_user.display_name,
}

return config

Expand Down
5 changes: 5 additions & 0 deletions lms/static/scripts/frontend_apps/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ export type ConfigObject = {
debug?: DebugInfo;
product: Product;

// Only present when an LTI user is logged-in
user?: {
display_name: string;
};

// Only present in "basic-lti-launch" mode.
canvas: {
// Only present in Canvas.
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/lms/resources/_js_config/__init___test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def test_it(
},
"mode": "basic-lti-launch",
"rpcServer": {"allowedOrigins": ["http://localhost:5000"]},
"user": {
"display_name": lti_user.display_name,
},
}

@pytest.mark.usefixtures("grouping_plugin")
Expand Down

0 comments on commit e9c3511

Please sign in to comment.