Member Junction
    Preparing search index...

    Function AuthorizeLoadedSession

    • Decides whether contextUser may address an already-loaded session: the AuthorizeSessionAccess decision, reading the session's conversation only when that decision needs it.

      AuthorizeSessionAccess decides a principal without a scope identity — a named user with no magic-link scope, the usual signed-in caller — from the owner check alone, and refuses a non-owner before it looks at anything else, so neither needs the conversation read. This function and that one encode the same rule on purpose and live together for that reason: change the rule there, change the read here. The AuthorizeLoadedSession table test in sessionAccess.test.ts fails if the two ever disagree.

      Parameters

      • session: MJAIAgentSessionEntity

        the session, loaded through the caller's own gate

      • contextUser: UserInfo

        the authenticated caller; the conversation, when read, is read as this user (RLS applies)

      • provider: IMetadataProvider

        the request-scoped provider

      Returns Promise<SessionAccessDecision>