Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot modify user created before migration when localDatastore is enabled. #1460

Closed
pjchavarria opened this issue Apr 12, 2016 · 13 comments
Closed

Comments

@pjchavarria
Copy link

I'm getting:
[Error]: cannot modify user ID_HERE (Code: 206, Version: 1.12.0)
When trying to update a user that was created before migrating from parse.com to mlab.com

Testing results

  • Both parse.com and AWS are using the same mlab database now, works fine using parse.com.
  • Login a the user with email or facebook give the same error.
  • Server running both locally and deployed on AWS give the same error.
  • Only happens to already created users, newly created users don't get that error.
  • It works fine for all users if i disable localDatastore when initializing the iOS SDK
  • Deleting the Instalations and Sessions for that user don't fix the error.
  • Tested with both versions of parse-server 2.1.6 and 2.2.6.
  • User data does get edited, but server returns
    400 Bad Request {"code":206,"error":"cannot modify user ID_HERE"}

Environment Setup

Swift project
iOS SDK 1.12.0

let configuration = ParseClientConfiguration {
            $0.applicationId = Keys().parseApplicationId()
            $0.clientKey = " "
            $0.server = Keys().parseServerURL()
            $0.localDatastoreEnabled = true
        }
Parse.initializeWithConfiguration(configuration)

Parse Server

"dependencies": {
    "express": "~4.13.x",
    "kerberos": "~0.0.x",
    "kue": "^0.10.5",
    "moment": "~2.12.0",
    "parse": "~1.8.3",
    "parse-server": "~2.2.6",
    "underscore": "~1.8.3"
  },
  "scripts": {
    "start": "node index.js"
  },
  "engines": {
    "node": ">=4.3"
  }

Steps to reproduce

  1. Enable localdatastore.
  2. Edit a user that was created before migration.

Pd. ParseServer is awesome, thanks for making it.

@refre5h
Copy link

refre5h commented Apr 12, 2016

We also have localDatastore enabled, and experienced similar thing. Possibly related: #1404

@drew-gross
Copy link
Contributor

Can you post the database contents for a user that is having the issue, and the exact request received by the server? The server logs all requests when you use the VERBOSE=1 environment variable.

@pjchavarria
Copy link
Author

Sure, this is one of the users with the problem, happens to all old users:

{
    "_id": "Bt5dy11isC",
    "aozoraUsername": "Usern",
    "_created_at": {
        "$date": "2015-07-29T02:43:34.338Z"
    },
    "_email_verify_token": "NvCSM7wHwRZgevXD4HxQlOiJo",
    "username": "usern",
    "_session_token": "FYKjnfTPrGsixzNmqBPxd8ELq",
    "email": "[email protected]",
    "emailVerified": false,
    "_hashed_password": "$2a$10$H8tyh4qU4ZpQQKLdBo12teXfo0Wvxpv4dWvv.os42pd.EJksjq69.",
    "_updated_at": {
        "$date": "2016-04-12T05:33:05.077Z"
    },
    "joinDate": {
        "$date": "2015-07-29T02:43:35.339Z"
    },
    "avatarThumb": "tfss-8be15f45-4867-4f42-b9c3-3507686b3eca-avatarThumb.png",
    "badges": [
        "Admin 2",
        "Kōhai"
    ],
    "_p_details": "UserDetails$X4IOQ2ZBET",
    "myAnimeListUsername": "usern",
    "banner": "tfss-0a2cdaf1-2d4d-4c34-8203-b92a693629d4-banner.png",
    "active": true,
    "activeStart": {
        "$date": "2016-04-12T05:30:14.829Z"
    },
    "activeEnd": {
        "$date": "2016-04-12T03:30:23.344Z"
    },
    "trialExpiration": {
        "$date": "2016-01-03T02:17:44.589Z"
    },
    "unlockedContent": [
        "com.anytap"
    ],
    "_rperm": [
        "*",
        "Bt5dy11isC"
    ],
    "_wperm": [
        "Bt5dy11isC"
    ]
}

Request:

PUT /parse/classes/_User/Bt5dy11isC HTTP/1.1
Host: hosthere.us-east-1.elasticbeanstalk.com
X-Parse-Client-Version: i1.12.0
Accept: */*
X-Parse-Session-Token: SESSION
X-Parse-Application-Id: APPID
X-Parse-Client-Key: 
X-Parse-Installation-Id: INSTALLATION
X-Parse-OS-Version: 9.3 (15E65)
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Type: application/json; charset=utf-8
Content-Length: 114
User-Agent: Aozora/121 CFNetwork/758.3.15 Darwin/15.4.0
Connection: keep-alive
X-Parse-App-Build-Version: 121
X-Parse-App-Display-Version: 1.7.1
Pragma: no-cache
Cache-Control: no-cache

{"email":"[email protected]","activeStart":{"__type":"Date","iso":"2016-04-12T22:25:04.502Z"},"active":true}```

@drew-gross
Copy link
Contributor

Thanks, I'll look into this.

@drew-gross
Copy link
Contributor

Also, I might not need it, but I also might: the contents of your _SCHEMA collection for _User.

@pjchavarria
Copy link
Author

Thanks!
The contents of _SCHEMA for _User:

{
    "_id": "_User",
    "_metadata": {
        "class_permissions": {
            "get": {
                "*": true
            },
            "find": {
                "*": true
            },
            "update": {
                "*": true
            },
            "create": {
                "*": true
            },
            "delete": {
                "*": true
            },
            "addField": {
                "*": true
            },
            "readUserFields": [],
            "writeUserFields": []
        },
        "auth_options": {
            "twitter": {
                "enabled": true
            },
            "anonymous": {
                "enabled": true
            },
            "_enable_by_default": true,
            "username": {
                "enabled": true
            },
            "facebook": {
                "enabled": true,
                "app_ids": [
                    "MY_APP_ID_HERE"
                ],
                "app_secrets": [
                    "MY_APP_SECRET_HERE"
                ]
            }
        }
    },
    "username": "string",
    "email": "string",
    "emailVerified": "boolean",
    "myAnimeListUsername": "string",
    "joinDate": "date",
    "aozoraUsername": "string",
    "avatarThumb": "file",
    "badges": "array",
    "banner": "file",
    "details": "*UserDetails",
    "following": "relation<_User>",
    "subscribedThreads": "relation<Thread>",
    "unlockedContent": "array",
    "activeStart": "date",
    "activeEnd": "date",
    "active": "boolean",
    "trialExpiration": "date",
    "ACL": "object"
}

Let me know if you need anything else 👍

@drew-gross
Copy link
Contributor

I noticed you have _session_token on your user, do you have revocable session tokens enabled for your Parse App? Currently Parse Server requires revocable session tokens.

@pjchavarria
Copy link
Author

Require Revocable Sessions was off in parse.com when i migrated to mlab.
I thought that was enabled by default on parse-server, how can i know if it's enabled?

@drew-gross
Copy link
Contributor

Unfortunately you'll need to go through the migrating to revocable sessions flow before using Parse Server: https://parse.com/tutorials/session-migration-tutorial otherwise users with old versions of your app will not be able to log in.

@pjchavarria
Copy link
Author

@drew-gross I've already migrated to the new mlab without revocable session tokens, now i'm stuck because i can't migrate again using revocables session tokens, only change the connection DB string, do you have any suggestion?

@benishak
Copy link
Contributor

I have the same issue

@drew-gross
Copy link
Contributor

The instructions in the guide will still work even after you've migrated your database.

@benishak
Copy link
Contributor

@drew where to put that line in iOS ? Inside the login function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants