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

Return concurrent sessions information to apply concurrent login limit in the mobile app

    XMLWordPrintable

Details

    • MOODLE_38_STABLE, MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-67807-master
    • Hide
      1. As an admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a Token in the mobile app service for any 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 'http://YOUR_SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_webservice_get_site_info&wstoken=WSTOKEN' | python -m "json.tool"

      4. Confirm that:
        • In the curl request response you see the field: limitconcurrentlogins set to 0
        • In the curl request response you don't see the field called usersessionscount
      5. Now, as admin, set the global admin setting "limitconcurrentlogins" to 2 for example (you can use the search box to find the setting)
      6. Log-in to the Moodle site using the user account used in Step #2
      7. Execute the same curl request as before
      8. Confirm that:
        • In the curl request response you see the field: limitconcurrentlogins set to 2
        • In the curl request response you see the field called usersessionscount set to 1
      9. Now, close the session you just open in the browser (logout)
      10. Execute the same curl request as before
      11. Confirm that:
        • In the curl request response you see the field: limitconcurrentlogins set to 2
        • In the curl request response you see the field called usersessionscount set to 0
      Show
      As an admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for any 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 'http://YOUR_SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_webservice_get_site_info&wstoken=WSTOKEN' | python -m "json.tool" Confirm that: In the curl request response you see the field: limitconcurrentlogins set to 0 In the curl request response you don't see the field called usersessionscount Now, as admin, set the global admin setting "limitconcurrentlogins" to 2 for example (you can use the search box to find the setting) Log-in to the Moodle site using the user account used in Step #2 Execute the same curl request as before Confirm that: In the curl request response you see the field: limitconcurrentlogins set to 2 In the curl request response you see the field called usersessionscount set to 1 Now, close the session you just open in the browser (logout) Execute the same curl request as before Confirm that: In the curl request response you see the field: limitconcurrentlogins set to 2 In the curl request response you see the field called usersessionscount set to 0

    Description

      This needs discussion but, should we apply the concurrent login limit when set?

      If the option is set, and the user reached the session limit (in web) should not we automatically fail WS requests? Especially those coming from the Moodle app?

      UPDATE

      After discussing this with some clients that have requested this feature, what the final user really wants is to stop people using the app if already have reached the session limit on web (generally is one session, the typical use case is to prevent someone from using the app when they have an active web session version).

      So there is not a real need for preventing WS requests, we can just implement some local (client side) code in the app to prevent the app from doing "something" until the web session is finished.

      "As a site admin I'll like the app to support Moodle concurrent login feature so that I can prevent my students to use different devices and sessions at the same time"

      So, to solve this, we just need to return some relevant information in the first WS call performed by the app (core_webservice_get_site_info), specifically:

      • If there is a concurrent limit set
      • How many active user sessions does the existing user already has

      This solution is not perfect because the mobile app will have to do some polling (when the concurrent limit is set in Moodle) to detect if the web session limit was reached for preventing the user to continue using the app. (however, we already do something similar so it should not be that bad)

      Attachments

        Activity

          People

            jleyva Juan Leyva
            jleyva Juan Leyva
            Pau Ferrer Pau Ferrer
            Jun Pataleta Jun Pataleta
            Gladys Basiana Gladys Basiana
            Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              19/Apr/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 45 minutes
                1h 45m