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

Email isn't set as username on signup #1340

Closed
meilers opened this issue Apr 2, 2016 · 30 comments
Closed

Email isn't set as username on signup #1340

meilers opened this issue Apr 2, 2016 · 30 comments

Comments

@meilers
Copy link

meilers commented Apr 2, 2016

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!

@flovilmart
Copy link
Contributor

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

@meilers
Copy link
Author

meilers commented Apr 2, 2016

@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.

@flovilmart
Copy link
Contributor

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

@meilers
Copy link
Author

meilers commented Apr 2, 2016

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.

@flovilmart
Copy link
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?

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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

@flovilmart
Copy link
Contributor

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

@meilers
Copy link
Author

meilers commented Apr 3, 2016

{
"_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"
}

@flovilmart
Copy link
Contributor

alright thx!

@flovilmart
Copy link
Contributor

Do you have a beforeSave on _User?

@meilers
Copy link
Author

meilers commented Apr 3, 2016

No - should I?

@flovilmart
Copy link
Contributor

nope, just to scratch out potential problems

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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?

@flovilmart
Copy link
Contributor

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

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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

@flovilmart
Copy link
Contributor

we changed a few things over time, and may have introduce a problem. can you run your server with VERBOSE=1 so we have all the logs?

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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

@flovilmart
Copy link
Contributor

use eb ssh

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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

@flovilmart
Copy link
Contributor

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html

that would be in /var/log/nodejs/

or in

/srv/...

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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"
}
}

@meilers
Copy link
Author

meilers commented Apr 3, 2016

hmmm is verbose not working?

@flovilmart
Copy link
Contributor

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

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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"
}
}

@flovilmart
Copy link
Contributor

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

@meilers
Copy link
Author

meilers commented Apr 3, 2016

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.' }

@flovilmart
Copy link
Contributor

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

@meilers
Copy link
Author

meilers commented Apr 4, 2016

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.

@meilers
Copy link
Author

meilers commented Apr 4, 2016

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. :)

@flovilmart
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants