Page 1 of 1

Pictures for Login Values

Posted: Thu Aug 04, 2016 5:32 am
by neuronhighway9522

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);
}


Pictures for Login Values

Posted: Sun Aug 07, 2016 6:48 am
by Serhii Kulibaba

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.


Pictures for Login Values

Posted: Tue Aug 09, 2016 12:39 am
by neuronhighway9522

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?


Pictures for Login Values

Posted: Tue Aug 09, 2016 10:45 am
by Serhii Kulibaba

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


Pictures for Login Values

Posted: Tue Aug 09, 2016 5:44 pm
by neuronhighway9522

ok thanks Ill try it there! Thanks Sergiy!