Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31465

Incorporate user suspension into webservices

XMLWordPrintable

    • MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_31_STABLE
    • MOODLE_32_STABLE
    • MDL-31465-master
    • Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Create a Token for the admin user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Create a new user and log in as that user.
      4. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken and the URL of your moodle instance

          curl 'http://localhost/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_update_users&users[0][id]=12&users[0][suspended]=1&wstoken=4cebbaa432c3c287f1d2d87b513aa65d' | python -m "json.tool"
          

      5. Make sure the user you logged in on web interface got his session killed and is not able to log in any more.
      6. Now, run the command again, but replace suspended parameter to 0 suspended=0:

        curl 'http://localhost/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_update_users&users[0][id]=12&users[0][suspended]=0&wstoken=4cebbaa432c3c287f1d2d87b513aa65d' | python -m "json.tool"
        

      7. Make sure you are able to login with the user you have created.
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the admin user Click on Site administration ► Plugins ► Web services ► Manage tokens Create a new user and log in as that user. Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the wstoken and the URL of your moodle instance curl 'http://localhost/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_update_users&users[0][id]=12&users[0][suspended]=1&wstoken=4cebbaa432c3c287f1d2d87b513aa65d' | python -m "json.tool" Make sure the user you logged in on web interface got his session killed and is not able to log in any more. Now, run the command again, but replace suspended parameter to 0 suspended=0 : curl 'http://localhost/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_update_users&users[0][id]=12&users[0][suspended]=0&wstoken=4cebbaa432c3c287f1d2d87b513aa65d' | python -m "json.tool" Make sure you are able to login with the user you have created.

      Currently the webservices do not allow the use of the user suspension feature.

      The only way to suspend a user is to change its auth plugin name, which has disadvantages, because it forces to keep track of the previous plugin in use before setting it to "nologin" for login deactivation.

      This improvement will allow one to specify the suspended value of the user, either 0 (if not suspended) or 1 (if suspended).

            andrews Andrew Solomon
            fabiomsouto Fábio Souto
            Simey Lameze Simey Lameze
            Dan Poltawski Dan Poltawski
            Rajesh Taneja Rajesh Taneja
            Votes:
            10 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.