Currently, I am working on a project using strongloop to develop a web service for user login. While my code is functioning properly and producing the desired output, the issue lies in the fact that it does not hide the password.
The result I am receiving is as follows:
{
"result": [{
"_id": 2,
"address": "abc",
"created_by": 1,
"created_date": "2016-03-04T00:00:00.000Z",
"firstname": "Anup",
"isdeleted": 0,
"lastname": "Deshpande",
"mobile_number": "9700128907",
"oldpassword": "string",
"profile_picturename": "anup.jpeg",
"role_id": 1,
"user_email_id": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="81e0eff4f1e5c1e8e5e4e0e4eff5e8f5f8afe2eeec">[email protected]</a>",
"user_password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
"user_status": 1
}]
}
I am looking for a way to either hide or remove the
"user_password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
field.
If anyone can guide me on how to achieve this in a remote method of strongloop, I would greatly appreciate it.
My current remote method code is as follows:
db.collection('users').find({
user_email_id : par,
user_password : sha256(par2)
}).toArray(function(err, result) {
// var passwordHash = hashPassword(user_password);
// console.log(passwordHash);
if (err) {
throw err;
}
if (result.length > 0) {
self.callback(null, result);
// db.disconnect();
} else {
self.callback(null, response);
// db.disconnect();
}
});
In this code, the "result" will provide all details, but I aim to conceal the password from the result.
Thank you in advance.