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

Let clients be able to distinguish different webservice_access_exception

    XMLWordPrintable

Details

    • MOODLE_38_STABLE
    • MOODLE_400_STABLE
    • MDL-67804-master
    • Hide
      Test
      1. As an admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a Token in the mobile app service for a new user on the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Open the console and execute this new curl request, replacing WSTOKEN with the token you just created and the SITE_URL with yours.

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_webservice_get_site_info&wstoken=WSTOKEN' | python -m "json.tool"

      4. Confirm that:
        • The curl request works, it does not return any exception and you retrieve information about the user and site
      5. As an admin, edit the profile of the user created in step 2, select the option "Suspended account"
      6. Execute the same curl request again and confirm that:
        • You receive as response a moodle_exception with error code: "wsaccessusersuspended"
      7. As an admin, edit the profile of the user created in step 2, unselect the option "Suspended account" and choose "No login" as authentication method.
      8. Execute the same curl request again and confirm that:
        • You receive as response a moodle_exception with error code: "wsaccessusernologin"
      9. Now, you need to manually update the database, table mdl_user, find the user created in step 2 and set the "deleted" field to 1
      10. Execute the same curl request again and confirm that:
        • You receive as response a moodle_exception with error code: "wsaccessuserdeleted"
      Show
      Test As an admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for a new user on the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console and execute this new curl request, replacing WSTOKEN with the token you just created and the SITE_URL with yours. curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_webservice_get_site_info&wstoken=WSTOKEN' | python -m "json.tool" Confirm that: The curl request works, it does not return any exception and you retrieve information about the user and site As an admin, edit the profile of the user created in step 2, select the option "Suspended account" Execute the same curl request again and confirm that: You receive as response a moodle_exception with error code: "wsaccessusersuspended" As an admin, edit the profile of the user created in step 2, unselect the option "Suspended account" and choose "No login" as authentication method. Execute the same curl request again and confirm that: You receive as response a moodle_exception with error code: "wsaccessusernologin" Now, you need to manually update the database, table mdl_user, find the user created in step 2 and set the "deleted" field to 1 Execute the same curl request again and confirm that: You receive as response a moodle_exception with error code: "wsaccessuserdeleted"

    Description

      In the app we want to logout the user if he's suspended. The problem is that we cannot distinguish the suspended user exception from other access exceptions since the specific data is only present in the debuginfo. This is because the error uses the websevice_access_exception class.

      If would be nice if Moodle could return a different errorcode, exception or message for each exception so the app can tell which error is happening.

      Example of what the app receives if a suspended user calls a WebService:

      {"exception":"webservice_access_exception","errorcode":"accessexception","message":"Access control exception"}

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              dpalou Dani Palou
              Dani Palou Dani Palou
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Gladys Basiana Gladys Basiana
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 12 minutes
                  3h 12m