Login

Hi. Struggling with the login function. In my ServerCode a use

var databaseId = "54545554545544554454545";
var username = request.get("username");
var password = request.get("password");

try {
// User login
var userLoginInfo = DatabaseUser.login(databaseId, username, password);

// Retrieve any additional information from UserProfile collection
// linked from the Users collection
var userProfile = DatabaseUser.retrieve(databaseId, userLoginInfo._id, "toProfiles", userLoginInfo.sessionToken);

var userData = {
"session": userLoginInfo.sessionToken,
"username": userProfile.username,
"email": userProfile.toProfile.email,
"country": userProfile.toProfile.country
};

response.success(userData, "application/json");

} catch (error) {
response.error({
"message": "Incorrect username or password."
}, 400);
}

When a do a test in ServerCode and script parameters a add username and password, then a use a username and password from the database. Have follow al the instruction, dont get it?
1 person has
this question
+1
Reply