Skip to content

Anonymous auth module should call manageSession to populate user info #371

@KofTwentyTwo

Description

@KofTwentyTwo

Problem

When using MOCK authentication, features that depend on user identity (like report sharing) don't work because the frontend never receives user info.

Root cause: useAnonymousAuthenticationModule.tsx in qqq-frontend-material-dashboard doesn't call manageSession, so loggedInUser is never set and QContext.userId remains undefined.

Example: SavedReport has userId field populated correctly by DynamicDefaultValueBehavior.USER_ID, but the share button is disabled because:

  • Record's userId = "dev-user" (correct)
  • Frontend's currentUserId = undefined (never set)
  • Comparison fails → "Only the owner of a Report may share it"

Proposed Solution

In useAnonymousAuthenticationModule.tsx, call manageSession after authentication to retrieve user info:

const setupSession = async () => {
   setIsFullyAuthenticated(true);
   Client.setGotAuthenticationInAllControllers();
   setCookie(SESSION_UUID_COOKIE_NAME, Md5.hashStr(`${new Date()}`), {path: "/"});
   
   // Add: call manageSession to get user info from backend
   const manageSessionResult = await Client.getInstance().manageSession();
   if (manageSessionResult?.values?.user) {
      setLoggedInUser(manageSessionResult.values.user);
   }
};

This mirrors what useOAuth2AuthenticationModule already does, ensuring consistent behavior across auth types.

Impact

Without this fix, any feature that compares QContext.userId against record ownership won't work with MOCK auth:

  • Report sharing (ShareableTableMetaData)
  • Any custom logic checking current user identity

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions