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

Parse.User.logIn says Invalid username/password from Cloud Code #706

Closed
step4 opened this issue Dec 18, 2018 · 2 comments
Closed

Parse.User.logIn says Invalid username/password from Cloud Code #706

step4 opened this issue Dec 18, 2018 · 2 comments

Comments

@step4
Copy link

step4 commented Dec 18, 2018

I have set up a Parse server accordingly and created a user with username "jon" and password "doe".
When I try to login from a browser with

const user = await Parse.User.logIn("jon","doe")

everything works fine and I get a ParseUser as a result.

For future SAML SSO reasons I want to try logging in via Cloud Code so I tried this simple example:

Parse.Cloud.define("user_login", async (request) => {
  const user = await Parse.User.logIn("jon", "doe")
  return user
})

now when I run

const u = await Parse.Cloud.run("user_login")

I get the error Uncaught (in promise) Error: Invalid username/password. ParseError: Invalid username/password.

I also tried the API Console from the Dashboard with a POST request to functions/user_login with the error

{
    "code": 101,
    "error": "Invalid username/password."
}

Maybe it is related to #189

@step4
Copy link
Author

step4 commented Dec 18, 2018

After hours of searching I found the root of the error.
In fact I create two API endpoints in my express app:

var api = new ParseServer({
  appId: "SocialCapital",
  masterKey: "socialcapitaldevelop",
  serverURL: `https://localhost/parse`,
  databaseURI: "mongodb://localhost/socialcapital",
  cloud: __dirname + "/cloud/main.js"
});
var api2 = new ParseServer({
  appId: "StudyQuiz",
  masterKey: "studyquizdevelop",
  serverURL: `https://localhost/parse2`,
  databaseURI: "mongodb://localhost/studygraph",
  allowClientClassCreation: false,
  enableAnonymousUsers: false
});

It turns out that the Cloud Code for my first api sends it request to the second api2.
Unfortunately I am not very good at backend development, but I had a quick look at the ParseServer class and found that at the beginning it requires:

Parse = require('parse/node').Parse,

and in line 87 ref the serverURL is set.

so maybe it is a problem with a 'static'-ish parse sdk node client?

A workaround is to just have one API created with new ParseServer.
Or maybe I didn't read a part in the docs and shouldn't create two API's in the beginning 😄

EDIT----
Sorry for closing

@step4 step4 closed this as completed Dec 18, 2018
@step4 step4 reopened this Dec 18, 2018
@flovilmart
Copy link
Contributor

Parse server does not support running 2 instances within the same runtime, because of the state of the JS SDK.

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

3 participants