Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-21238

Remove the need for Programming Rights in XWiki.XWikiUserProfileSheet

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • None
    • 14.10
    • User - User Profile
    • None
    • Unknown

    Description

      Right now the code is:

      #if ($hasAdmin && "$!request.userId" != "" && ($request.action == "disable" || $request.action == "enable") && $services.csrf.isTokenValid($request.csrf))
      #set ($user = $xwiki.getUser($request.userId))
      #set ($isCurrentUser = $user.getUser().userReference.equals($xcontext.userReference))
      #if (!$isCurrentUser && $user.getUser().exists($xcontext.context))
        #set ($disabled = ($request.action == "disable"))
        #set ($discard = $user.setDisabledStatus($disabled))
        #set ($success = ($disabled && $user.isDisabled()) || (!$disabled && !$user.isDisabled()))
      #else
        #set ($success = false)
      #end
      

      The problem is that User#getUser() requires PR:

          /**
           * Expose the wrapped XWikiUser object. Requires programming rights.
           *
           * @return The wrapped XWikiUser object, or {@code null} if the user does not have programming rights.
           */
          @Programming
          public XWikiUser getUser()
          {
              if (hasProgrammingRights()) {
                  return this.user;
              }
              return null;
          }
      

      We need to expose more public APIs to be able to know if the current user reference matches a given reference and to check for its existence (not sure why we need this since the current user has to exist, no?)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: