Skip to content

Email isn't set as username on signup #1340

Closed

Description

@meilers

I'm running the latest Parse-Server (2.1.6) and Parse (1.6.12) on my AWS EB instance. I noticed that when the user signs up via the iOS or Android clients with signUpInBackground, the user's username becomes a random string (e.g. "username": "52927b5594f76b391cc6fbdcbe2da63c"), even though I set the user's username to be the email.

Therefore, user's can't relogin because their email isn't associated to their username.

Here's a snippet of the Android code:

        ParseUser user = new ParseUser();

        if( ParseAnonymousUtils.isLinked(ParseUser.getCurrentUser()) ) {
            user = ParseUser.getCurrentUser();               // Sign Up current anonymous user
        }

        user.setUsername(email);
        user.setPassword(password);
        user.setEmail(email);
        user.put("firstName", firstName);
        user.put("lastName", lastName);

        user.signUpInBackground(new SignUpCallback() {
            public void done(ParseException e) {
                if (e == null) {
                    saveInstallation(new SaveCallback() {
                        @Override
                        public void done(ParseException e) {

                            if( callback != null ) {
                                callback.onSuccess();
                            }
                        }
                    });
                } else {
                    // Sign up didn't succeed. Look at the ParseException
                    // to figure out what went wrong
                    if( callback != null ) {
                        callback.onFailure(e.getMessage());
                    }
                }
            }
        });

Any ideas on why this is happening? Thanks!

Activity

  1. flovilmart commented on Apr 2, 2016

    @flovilmart
    Contributor

    The latest parse server is 2.2.4 ;) can you update and see if the issue is still here?

  2. meilers commented on Apr 2, 2016

    @meilers
    Author

    @flovilmart Sorry for the delay. Yes, I finally managed to update to 2.2.4 on AWS can I still see the same issue. The username is still generated and isn't given the email value I give it at sign up, both on iOS and Android.

  3. flovilmart commented on Apr 2, 2016

    @flovilmart
    Contributor

    Ok that's annoying, I'll have a look before next week

  4. meilers commented on Apr 2, 2016

    @meilers
    Author

    Ok thanks. I'll be downgrading to 2.0 in the meantime, because it's pretty critical to me that users can't log back in.

  5. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    That's very very odd as this is properly covered by unit tests here.

    Can you run the server with environment var VERBOSE=1 and let us know the trace of requests/responses upon signup?

  6. meilers commented on Apr 3, 2016

    @meilers
    Author

    Here is is. Here are the headers for sign up:

    1q

    With JSON payload:
    screen shot 2016-04-03 at 1 24 48 pm

    Here are the response headers:
    screen shot 2016-04-03 at 1 25 10 pm

    With JSON:
    screen shot 2016-04-03 at 1 25 30 pm

    Now, when I do a login, right after (in between the user gets logged in anonymously because I log out), here is the request:
    1x

    With JSON:
    screen shot 2016-04-03 at 1 27 19 pm

    And response:

    screen shot 2016-04-03 at 1 27 26 pm

    With JSON:
    screen shot 2016-04-03 at 1 27 33 pm

  7. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    What does it look like in mongodb? the randomly generated string is generated at the time we link/create an anonymous user.

  8. meilers commented on Apr 3, 2016

    @meilers
    Author

    {
    "_id": "DpYUKuoTqx",
    "_rperm": [
    "DpYUKuoTqx",
    "*"
    ],
    "_wperm": [
    "DpYUKuoTqx"
    ],
    "username": "cf421f4bac640e6cdd582f036beee972",
    "_updated_at": {
    "$date": "2016-04-03T17:22:55.860Z"
    },
    "_created_at": {
    "$date": "2016-04-03T17:20:35.054Z"
    },
    "_auth_data_anonymous": null,
    "lastName": "Test",
    "firstName": "Test",
    "email": "test16@test.com",
    "_hashed_password": "$2a$10$usYnVR.Pn/A7Nc5ZPzpReOGfDTNUUwH9/FfKZh1XWRyD5Rjlh7FaG"
    }

  9. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    alright thx!

  10. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    Do you have a beforeSave on _User?

  11. meilers commented on Apr 3, 2016

    @meilers
    Author

    No - should I?

  12. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    nope, just to scratch out potential problems

  13. meilers commented on Apr 3, 2016

    @meilers
    Author

    Hmmm... I just noticed I do a saveEventually when I login anonymously (before sign up):

    ParseAnonymousUtils.logIn(new LogInCallback() {
                @Override
                public void done(ParseUser user, ParseException e) {
                    if (e == null) {
                        user.saveEventually();
                        saveInstallation(new SaveCallback() {
                            @Override
                            public void done(ParseException e) {
                        });
                    } else {
                        // Sign up didn't succeed. Look at the ParseException
                        // to figure out what went wrong
                    }
                }
            });
    

    Could that be a problem?

  14. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    yeah, that may be related as you may introduce a race condition here... ParseAnonymousUtils.logIn will save your user anyway

  15. meilers commented on Apr 3, 2016

    @meilers
    Author

    Weird it's working on older versions of Parse-Server though. Let me test without it.

  16. 1 remaining item

  17. meilers commented on Apr 3, 2016

    @meilers
    Author

    Yeah - AWS Beanstalk is slow today. I'm requesting the logs as we speak.

  18. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    use eb ssh

  19. meilers commented on Apr 3, 2016

    @meilers
    Author

    ok i'm in with ssh. Where can I find the logs?

  20. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor
  21. meilers commented on Apr 3, 2016

    @meilers
    Author

    PUT /parse/classes/_User/DpYUKuoTqx { host: 'parse-server-birder.elasticbeanstalk.com',
    'x-real-ip': '10.164.111.163',
    'x-forwarded-for': '24.203.158.119, 10.164.111.163',
    'content-length': '165',
    'accept-encoding': 'gzip',
    'content-type': 'application/json',
    'user-agent': 'Parse Android SDK 1.13.0 (com.sobremesa.birdwatching/36) API Level 23',
    'x-parse-app-build-version': '36',
    'x-parse-app-display-version': '1.7',
    'x-parse-application-id': 'xxxxxxxxxxxxx',
    'x-parse-client-key': 'xxxxxxxxxxxxx',
    'x-parse-client-version': 'a1.13.0',
    'x-parse-installation-id': '6fffc9ca-eeca-4b3b-82b9-e8a70987f1db',
    'x-parse-os-version': '6.0.1',
    'x-parse-session-token': 'r:a9a539a5979e05f959fe6f28454a131d',
    'x-forwarded-port': '80',
    'x-forwarded-proto': 'http' } {
    "lastName": "Test",
    "firstName": "Test",
    "email": "test16@test.com",
    "password": "test",
    "username": "test16@test.com",
    "authData": {
    "anonymous": null
    },
    "objectId": "DpYUKuoTqx"
    }
    response: {
    "response": {
    "updatedAt": "2016-04-03T17:22:55.860Z"
    }
    }

  22. meilers commented on Apr 3, 2016

    @meilers
    Author

    hmmm is verbose not working?

  23. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    no calls before or after? this is what you get with VERBOSE

  24. meilers commented on Apr 3, 2016

    @meilers
    Author

    This what I have just before...
    PUT /parse/classes/_Installation/YtmhOeQ1JO { host: 'parse-server-birder.elasticbeanstalk.com',
    'x-real-ip': '10.164.111.163',
    'x-forwarded-for': '24.203.158.119, 10.164.111.163',
    'content-length': '119',
    'accept-encoding': 'gzip',
    'content-type': 'application/json',
    'user-agent': 'Parse Android SDK 1.13.0 (com.sobremesa.birdwatching/36) API Level 23',
    'x-parse-app-build-version': '36',
    'x-parse-app-display-version': '1.7',
    'x-parse-application-id': 'xxxxxxxxx',
    'x-parse-client-key': 'xxxxxxxxx',
    'x-parse-client-version': 'a1.13.0',
    'x-parse-installation-id': '6fffc9ca-eeca-4b3b-82b9-e8a70987f1db',
    'x-parse-os-version': '6.0.1',
    'x-parse-session-token': 'r:a9a539a5979e05f959fe6f28454a131d',
    'x-forwarded-port': '80',
    'x-forwarded-proto': 'http' } {
    "userId": "DpYUKuoTqx",
    "user": {
    "__type": "Pointer",
    "className": "_User",
    "objectId": "DpYUKuoTqx"
    },
    "objectId": "YtmhOeQ1JO"
    }
    response: {
    "response": {
    "updatedAt": "2016-04-03T17:22:56.723Z"
    }
    }

  25. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    ok so if there is no other call on _User/DpYUKuoTqx that's really odd

  26. meilers commented on Apr 3, 2016

    @meilers
    Author

    Just noticed this. When I logout after signing up, and log in anonymously, it returns the same _User/DpYUKuoTqx:

    POST /parse/users { host: 'parse-server-birder.elasticbeanstalk.com',
    'x-real-ip': '10.164.111.163',
    'x-forwarded-for': '24.203.158.119, 10.164.111.163',
    'content-length': '72',
    'accept-encoding': 'gzip',
    'content-type': 'application/json',
    'user-agent': 'Parse Android SDK 1.13.0 (com.sobremesa.birdwatching/36) API Level 23',
    'x-parse-app-build-version': '36',
    'x-parse-app-display-version': '1.7',
    'x-parse-application-id': 'xxxxxxxx',
    'x-parse-client-key': 'xxxx',
    'x-parse-client-version': 'a1.13.0',
    'x-parse-installation-id': '6fffc9ca-eeca-4b3b-82b9-e8a70987f1db',
    'x-parse-os-version': '6.0.1',
    'x-forwarded-port': '80',
    'x-forwarded-proto': 'http' } {
    "authData": {
    "anonymous": {
    "id": "aaf2bbf0-a113-49b4-bbd2-a75f65ca54e5"
    }
    }
    }
    response: {
    "status": 201,
    "response": {
    "objectId": "DpYUKuoTqx",
    "createdAt": "2016-04-03T17:20:35.054Z",
    "sessionToken": "r:a9a539a5979e05f959fe6f28454a131d"
    },
    "location": "http://parse-server-birder.elasticbeanstalk.com/parse/users/DpYUKuoTqx"
    }

    Right after, there's the log in call that fails:

    GET /parse/login { host: 'parse-server-birder.elasticbeanstalk.com',
    'x-real-ip': '10.164.111.163',
    'x-forwarded-for': '24.203.158.119, 10.164.111.163',
    'content-length': '64',
    'accept-encoding': 'gzip',
    'content-type': 'application/json',
    'user-agent': 'Parse Android SDK 1.13.0 (com.sobremesa.birdwatching/36) API Level 23',
    'x-parse-app-build-version': '36',
    'x-parse-app-display-version': '1.7',
    'x-parse-application-id': 'xxxxx',
    'x-parse-client-key': 'xxxxx',
    'x-parse-client-version': 'a1.13.0',
    'x-parse-installation-id': 'fd1c71a3-d441-47f3-a5d3-8accadd54cf7',
    'x-parse-os-version': '6.0',
    'x-forwarded-port': '80',
    'x-forwarded-proto': 'http' } {
    "username": "test15@test.com",
    "password": "test"
    }
    error: ParseError { code: 101, message: 'Invalid username/password.' }

  27. flovilmart commented on Apr 3, 2016

    @flovilmart
    Contributor

    it's very odd that "anonymous": { "id": "aaf2bbf0-a113-49b4-bbd2-a75f65ca54e5" } returns your user.

  28. meilers commented on Apr 4, 2016

    @meilers
    Author

    Have you tested on your side? I tried with Parse-Server 2.2.4, and 2.1.6, and still the same issue. I also removed the "saveEventually", but it didn't help.

  29. meilers commented on Apr 4, 2016

    @meilers
    Author

    So I just tried deploying the app on Heroku instead of AWS... and now it works. SO INFURIATING. I have no idea why it had that behaviour on AWS. Sorry for wasting your time, and a huge thank you for your contribution to Parse. :)

  30. flovilmart commented on Apr 4, 2016

    @flovilmart
    Contributor

    no problem! here to help. That's odd what's happening on AWS. But if you can stick to heroku, you'll be better off for now, Elastic Beanstalk is not that easy to manage. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions