Inconsistent system function documentation/behavior
C
Christian Klaussner
I noticed that
context.user
in system functions doesn't always work as documented.For example, the documentation states that "You can dynamically reference the active user of a Function in the Function’s source code with context.user." (https://docs.mongodb.com/stitch/functions/#active-user) and that "A System Function is a Function where the active user is a system user instead of an application user." (https://docs.mongodb.com/stitch/functions/#system-functions). However, when I run a system function as a logged in user with the browser SDK,
context.runningAsSystem()
returns true
and context.user
is the logged in user, not a system user.When I run the same system function using the Stitch UI, it works as documented: If it's run as a user, the active user is set correctly and the function doesn't run with system privileges, i.e.,
context.runningAsSystem()
returns false
.Which behavior is correct? Can I rely on the
context.user
object containing information about the user who called the system function or is that a bug in Stitch?I created a reproduction repository here: https://github.com/klaussner/stitch-system-function-reproduction.
Drew DiPalma
Hi Folks!
As part of our upcoming re-brand of "Stitch" to "Realm" we'll also be migrating our feedback forum and joining the rest of MongoDB at feedback.mongodb.com – as part of that transition, we'll be shutting down this forum. We're still keeping track of this feedback and all of the related comments/discussions, but have only migrated feedback with 5+ votes at this time. If you would like us to continue to track this item in the new forum please let us know.