-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Create a session token in cloud code without password #6641
Comments
I think you should pass in an installationId. See my #6636 (comment) to see why it wouldn't work (similar concept). I did a PR a while ago for this exact issue parse-community/Parse-SDK-JS#1031 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@davbeck did you get it to work ? |
Reopening as there has been recent activity and the issue still seems to exist. |
@Chocolladin Would you want to submit a PR with a failing test so we can look into it? |
Dear Manuel, that you for your quick response. I'am not very familiar with PR and github, not being a dev in the first place, i will try though to be as precise as possible. Here is what i am trying to achieve : Client side (react-native),
On parse server, Step 3 isnt working and here is the code i am using :
NB: Moreover, i am not using the parse-server-firebase authentication module because of 2 reasons :
Can this be enough for now ? Thank you, Regards, Bertrand |
Hi @Chocolladin Did you find any solution ? Regards, Killian |
This should be possible. If we can get a failing test, that would be a first step to solve this. If you need any guidance for how to write a test, please feel free to ask, it should be fairly simple in this case. |
Hi @mtrezza, Can you explain me how to write a test ? I should be able to do it. |
Sure, we do have a contribution guide but unfortunately it is very verbose and needs refactoring, so I will just mention the main steps here:
Additionally, see this blog post for a step-by-step guide, it may not be 100% what you need, but it is a good guidance. |
@mtrezza |
So, on paper this should already be possible? |
on paper, getting the session token on a user queried using the master key should work (I added the failing test), and I'm trying to use the |
Hi everyone, I really need this behavior to work for my application, does anyone have a way to fix it? |
Dear Killian @Yurgal , I am using a workaround for the time being to achieve what i am trying to. As the user authentication is based on a third party service (In my case, firebase), i managed to force the login in cloud code by setting a random password and logging in with it. See function below :
The resulting user can then be passed back to client and .getSessionToken() can be called on it. Hoping this can be of any help to you, Best Regards, Bertrand. |
Thanks @Chocolladin, but in my case it doesn't work. I want a user to be able to login as another user (if he has the right rights) with the username/email/id and without changing his password. |
Little note @Chocolladin , Math.random is no t secure to be use for passwords. You should use: |
I've submitted a pull request (#7406) adding a Parse Server REST endpoint for master key clients to create user sessions without access to the user's credentials. It's my first PR to the project, so please let me know if I need to do anything differently, especially security. ✔️ Add /loginAs REST endpoint to Parse Server - merged! |
Nicely done @GormanFletcher! Do you plan to add this to the JS SDK so it can be easily used in cloud code without needing to use the REST API? |
Can this be closed? @mtrezza? |
Closing via #7406 |
I'm trying to login a user from a cloud function. The idea is to return a session token and then have the client use
PFUser.become
. According to the documentation forgetSessionToken
should work if using the master key:But this doesn't seem to work. It still returns
undefined
using the following code:Similarly trying to call login without a username or password fails:
I could set a new password and login that way, but it feels like there should be a better solution?
The text was updated successfully, but these errors were encountered: