Uploaded image for project: 'Nuxeo Documentation'
  1. Nuxeo Documentation
  2. NXDOC-2025

Correct Auth.Logout sample in documentation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 9.10
    • Fix Version/s: 9.10, 10.10, 11.1
    • Component/s: None

      Description

      According to https://doc.nuxeo.com/nxdoc/automation-scripting/#logout , Auth.Logout() can be called from JavaScript in an automation.

      However, the Automation Scripting:

      function run(input, params) {
          var doc;
              doc = Auth.LoginAs(input, {});
              doc = Auth.Logout(doc);
        return doc;
      }
      

      optionally called through an Automation Chain:

      - Context.FetchDocument
      - javascript.AS_SetPerms2
      

      called by an User Action chokes with

      Caused by: java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.runtime.Undefined to jdk.nashorn.api.scripting.ScriptObjectMirror
              at java.lang.invoke.MethodHandleImpl.newClassCastException(MethodHandleImpl.java:361)
              at java.lang.invoke.MethodHandleImpl.castReference(MethodHandleImpl.java:356)
              at jdk.nashorn.internal.scripts.Script$Recompilation$41$33972AA$\^eval\_.Logout(<eval>:817)
              at jdk.nashorn.internal.scripts.Script$Recompilation$45$28AA$\^eval\_$cu1$restOf.run(<eval>:6)
              at org.nuxeo.automation.scripting.internals.ScriptingOperationImpl$Runnable$$NashornJavaAdapter.run(Unknown Source)
      

      Expected: behavior of code matching documented behavior

      Notice: Auth.LoginAs works OK

      Workaround; "export" authentication operations to Automation Chain, not Script.

      Documentation error: it should be written

      doc = Auth.Logout(doc, {});
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: