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

📙 Possible incongruity on beforeLogin cloudCode documentation #701

Open
AugustoAmaral opened this issue Jan 27, 2020 · 6 comments
Open

📙 Possible incongruity on beforeLogin cloudCode documentation #701

AugustoAmaral opened this issue Jan 27, 2020 · 6 comments

Comments

@AugustoAmaral
Copy link
Contributor

@AugustoAmaral AugustoAmaral commented Jan 27, 2020

I was reading the parse cloud code docs on this part and saw :
The user is not available on the request object - the user has not yet been provided a session until after beforeLogin is successfully completed

And after doing some tests, I realized that this information was incomplete, because I got this as answer:
image

Another information that can be considered relevant is that parse user object is not the original request one, but the one from database and I don't know why, and i think this cloudCode run beforeSave ParseUser.

I checked the code and couldn't really understand the code, since I'm a newbie 🤣. but I would like to know if what I perceived proceeds.

@TomWFox
Copy link
Member

@TomWFox TomWFox commented Jan 27, 2020

@omairvaiyani could you take a look at this?

@davimacedo
Copy link
Member

@davimacedo davimacedo commented Jan 27, 2020

@AugustoAmaral would you be able to describe the steps to reproduce the problem?

@AugustoAmaral
Copy link
Contributor Author

@AugustoAmaral AugustoAmaral commented Jan 27, 2020

@davimacedo I am using a custom authProvider and was trying to write an beforeLogin cloud function to update the roles based on authData info.
So when I try to compare the authData from request and from database, they're the same, even if I send a different request, but in afterSave function, I see the original request.
Another strange thing is the beforeSave is never called, just the afterSave..

@AugustoAmaral
Copy link
Contributor Author

@AugustoAmaral AugustoAmaral commented Jan 27, 2020

The solution I have found, is update all roles on every afterSave, once every change of authData trigger afterSave function

@omairvaiyani
Copy link
Contributor

@omairvaiyani omairvaiyani commented Jan 29, 2020

The docs aren't clear enough I guess

The request.user property is different to request.object. user is for the current requesting user, i.e. the authenticated requester. In the case of beforeLogin, the user has not yet been authenticated, and therefore, request.user is undefined. The request subject on the other hand, is defined under request.object, which in this case is the user's object - minus the session token.

@AugustoAmaral
Copy link
Contributor Author

@AugustoAmaral AugustoAmaral commented Feb 4, 2020

Got it, I'll create a PR and make an improvement to make it clear

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

Successfully merging a pull request may close this issue.

None yet
4 participants