login script not functioning.

Ok, apparently my user login script is not working. Can someone please advise.
// This script works together with RegisterNewUse script (plug-in)
// This scripts logs a user in and retreives any additional information
// from the UserProfile collection
// This script requires creating a custom UserProfile collection. Then creating
// a 'user_profile' column in Users collection with Pointer type
// referencing UserProfile collection.
// See more in tutorial:

var databaseId = "5b6aaca00f0d31345c60f9c1";
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, "toProfile", userLoginInfo.sessionToken);

var userData = {
"session": userLoginInfo.sessionToken,
"username": userProfile.username,

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

} catch (error) {
"message": "Incorrect username or password."
}, 400);
1 person has
this question