Skip to content

fix(storages): resolve departmentName in file storage user organizations - #138

Merged
BatLeDev merged 1 commit into
masterfrom
fix-file-storage-department-name
Aug 27, 2026
Merged

fix(storages): resolve departmentName in file storage user organizations#138
BatLeDev merged 1 commit into
masterfrom
fix-file-storage-department-name

Conversation

@BatLeDev

Copy link
Copy Markdown
Member

Resolve departmentName when building user.organizations in the file storage backend.

What changed:

  • api/src/storages/file.ts: resolve departmentName from orga.departments in getUserOrgas when a member has a department ID.
  • tests/features/file-storage.unit.spec.ts: added a unit test verifying that department and departmentName are correctly populated on user.organizations.

Why:

When using FileStorage, getUserOrgas only copied the department ID (member.department) onto the member record without resolving its display name (departmentName). As a result, the session token lacked departmentName (leaving sessionState.account.departmentName undefined), breaking consuming services like Data-Fair which rely on it to suffix _ownerName on /own/* routes.
The Mongo storage backend already stores and resolves departmentName, and FileStorage.findMembers was already performing this resolution.

The file storage builds user.organizations from the organizations
members but only copies the department id: the session token of a
department member carries department without departmentName, so
sessionState.account.departmentName is undefined in every consuming
service (data-fair reads it to suffix _ownerName on the own/ routes).

The mongo storage persists departmentName on the user document, and
findMembers already resolves it from the organization departments;
apply the same resolution in getUserOrgas.
@github-actions github-actions Bot added the fix label Aug 27, 2026
@BatLeDev
BatLeDev merged commit 7082b81 into master Aug 27, 2026
3 of 4 checks passed
@BatLeDev
BatLeDev deleted the fix-file-storage-department-name branch August 27, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant