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

Incorporate user suspension into webservices

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.7, 2.1.4, 2.2.1, 3.1.2
    • Fix Version/s: 3.2
    • Component/s: Web Services
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-31465-master

      Description

      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).

        Attachments

          Activity

            People

            Assignee:
            andrews Andrew Solomon
            Reporter:
            fabiomsouto Fábio Souto
            Peer reviewer:
            Simey Lameze
            Integrator:
            Dan Poltawski
            Tester:
            Rajesh Taneja
            Participants:
            Component watchers:
            Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            10 Vote for this issue
            Watchers:
            18 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              5/Dec/16