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

External function core_user_add_user_devices doesn't prevent duplicate devices

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.5, 2.8.3
    • Fix Version/s: 2.7.8, 2.8.6
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Create a Token for one user (student account):
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Next, do the following calls .
        • First call, just copy and paste the request (you need to replace the wstoken and the URL of your moodle instance). It will create a device in your user_devices table
        • Second call, change only the pushid value. Check that the user_device entry was updated reflecting the new pushid value
        • Third call, change again the pushid value with a different new one and the uuid value. Check that a new device is created in the user_device table
        • You also need to replace the wstoken and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'appid=commoodlemobile&name=occam&model=Nexus&platform=Android&version=4&pushid=237823&uuid=ABCDEF&wsfunction=core_user_add_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed
          

      Show
      Enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for one user (student account): Click on Site administration ► Plugins ► Web services ► Manage tokens Next, do the following calls . First call, just copy and paste the request (you need to replace the wstoken and the URL of your moodle instance). It will create a device in your user_devices table Second call, change only the pushid value. Check that the user_device entry was updated reflecting the new pushid value Third call, change again the pushid value with a different new one and the uuid value. Check that a new device is created in the user_device table You also need to replace the wstoken and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'appid=commoodlemobile&name=occam&model=Nexus&platform=Android&version=4&pushid=237823&uuid=ABCDEF&wsfunction=core_user_add_user_device&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-48443-master

      Description

      This error is happening mostly in Windows devices where the Push key/identifier changes but the UUID not

      The problem is that this create duplicate devices that will receive the same notification because the Push keys/identifiers are valid (even when they were changed in the device).

      So if you have the same device with 5 different Push key/identifiers you will receive the same notification 5 times

      This will require create an additional UNIQUE index userid-uuid-app for preventing duplicates and search the device (note that the same device can be used by two or more users, a shared tablet in schools etc..)

      Note: The user can prevent this in their messaging options disabling the duplicate devices

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Dani Palou
              Integrator:
              Dan Poltawski
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/15