-
Type: Bug
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 11.4
-
Component/s: Authentication
-
Tags:
-
Backlog priority:710
-
Team:FG
-
Sprint:nxFG 11.3.1
-
Story Points:1
This used to work in 10.10, fails (see below) in 11.4:
1. Have a scheduler
<extension target="org.nuxeo.ecm.core.scheduler.SchedulerService" point="schedule"> <schedule id="CLEANUP_DEMO"> <eventId>cleanupDemo</eventId> <eventCategory>default</eventCategory> <!-- Every hour --> <cronExpression>0 0 0/1 * * ?</cronExpression> </schedule> </extension>
2. And an event handler (Studio => not a Java listener):
<extension target="org.nuxeo.ecm.core.operation.OperationServiceComponent" point="event-handlers"> <handler chainId="javascript.Admin_DemoScheduledCleanup"> <event>cleanupDemo</event> </handler> . . .
3. The JS is very simple:
function run(input, params) { var docs, nxql, found; Auth.LoginAs(null, {}); // <========== Fails here docs = Repository.Query( . . . . )
The JS fails with NPE when calling the operation, because (looking at the source code) it expects a principal but there is none (it fails at line 55)
#54 Principal origPrincipal = ctx.getPrincipal(); #55 lc = Framework.loginSystem(origPrincipal.getName());
Reminder : this worked fine in 10.10, so something changed in between.
Workaround : explicitly set the user to a an administrator:
Auth.LoginAs(null, {"name": "Administrator"});
- Is referenced in