neuronhighway9522
Posts: 0
Joined: Sun Oct 19, 2014 2:42 am

Pictures for Login Values

I want to use two photos from the data base as login values (key1, key2)

I currently have these values as files in the USER collection, and adapted a login script to look for these values instead of username and password. I tested the service in the run tab and got a 400 error... How do I implement this? with many thanks FYI.... I put my real database_id where "mydatabase_id" is on the the code listed below, I just didnt want to post it .....

// This scripts logs a user in and retreives any additional information
// from the UserProfile collection

var databaseId = "mydatabase_id";

var key1 = request.get("key1");
var key2 = request.get("key2");

try {
// User login
var userLoginInfo = DatabaseUser.login(databaseId, key1, key2);

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

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

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

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Pictures for Login Values

Hello,

Please be sure these key1 and key2 are not empty and exist in your database. E.g. print them to the console to check their values.

neuronhighway9522
Posts: 0
Joined: Sun Oct 19, 2014 2:42 am

Pictures for Login Values

Is it better to store these key 1 and key 2 values in the user section or in the collection where we store the rest of the information about the users.

Since they are photos, clearly they are stored in the files section but what collection would be better to access in this instance?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Pictures for Login Values

It is better to keep all information about the user in the collection "users". So keep these values at the same collection.

neuronhighway9522
Posts: 0
Joined: Sun Oct 19, 2014 2:42 am

Pictures for Login Values

ok thanks Ill try it there! Thanks Sergiy!

Return to “Issues”