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

WebService add_user_device doesn't store entries for different users using the same push key

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6.4, 2.7.1
    • Fix Version/s: 2.6.5, 2.7.2
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide

      Note: I've bumped the version number so the upgrade.php is executed

      Once the site is upgraded, you need to test the WebService:

      Enable Web Services in Advanced features
      Enable Web services for mobile devices in Plugins / WebServices / Services
      Use this client: https://gist.github.com/jleyva/6669774
      The required curl.php file is here: https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/curl.php

      You need two tokens (for different users) related to the Mobile service:

      Create Token:
      Click on Site administration ► Plugins ► Web services ► Manage tokens
      Click add, select user and service (mobile)

      You need two tokens for two different users at the same site:

      1 Edit the client file for replacing the first token and the moodle url
      2 Run the client file in a browser, it should return just []
      3 You should check directly in the Moodle database that a new entry was created (user_devices table) for the user linked to the token
      3 Edit the client file again, replace the token with the second one you created
      4 Run the client in a browser
      5 Check in the Moodle database again that you have two entries in the user_devices tables, the field values must be the same (except for the id and userid fields)
      6 Run the client again in the browser, you will receive a message "Warning this key already exists for this user"
      7 Check that the Unique index pushid, platform in the user_devices table was deleted after upgrade

      Show
      Note: I've bumped the version number so the upgrade.php is executed Once the site is upgraded, you need to test the WebService: Enable Web Services in Advanced features Enable Web services for mobile devices in Plugins / WebServices / Services Use this client: https://gist.github.com/jleyva/6669774 The required curl.php file is here: https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/curl.php You need two tokens (for different users) related to the Mobile service: Create Token: Click on Site administration ► Plugins ► Web services ► Manage tokens Click add, select user and service (mobile) You need two tokens for two different users at the same site: 1 Edit the client file for replacing the first token and the moodle url 2 Run the client file in a browser, it should return just [] 3 You should check directly in the Moodle database that a new entry was created (user_devices table) for the user linked to the token 3 Edit the client file again, replace the token with the second one you created 4 Run the client in a browser 5 Check in the Moodle database again that you have two entries in the user_devices tables, the field values must be the same (except for the id and userid fields) 6 Run the client again in the browser, you will receive a message "Warning this key already exists for this user" 7 Check that the Unique index pushid, platform in the user_devices table was deleted after upgrade
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull from Repository:
    • Pull 2.7 Branch:
      MDL-45041_27_STABLE
    • Pull Master Branch:

      Description

      This may happen if you have two different users in the same Moodle site (a student and teacher account or manager account, etc...) and you want to add both in the Mobile app. Push keys are unique for apps, so the same push key will be valid for two users in the same site.

      The problem is that we prevent duplicate entries for the pair "pushid, platform", we should delete the code check and also the unique key (in upgrade.php and install.xml)

      <KEY NAME="pushid-platform" TYPE="unique" FIELDS="pushid, platform"/>
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    8/Sep/14