Make sure your hashed Joomla password is in your Mongo Db; from your Joomla app you need a call to do that job. In php a curl job can do that job.
Joomla uses bcrypt to hash its passwords so you need a node package for that. There's several and I only succeeded with bcryptjs ; 3.Now you need to make the authentication mechanism in your Node app that checks against the db. This is Mongoose talking to Mongo. I'll show the snippet where bcrypt makes the comparison.
function authenticate(req, res, next) { var body = req.body;
User.find({username: body.username}, function (err, theuser) { if (theuser.length == 1) { bcrypt.compare(body.password, theuser[0].password, function (err, ismatch) { if(ismatch) { user = {joomlaid:theuser[0].joomlaid,username:theuser[0].username, name:theuser[0].name, useremail:theuser[0].useremail}; console.log('found user: ' + JSON.stringify(user)); next(); } else { console.log("user found but no matching passwords" + ismatch); res.status(401).end('Password incorrect'); } }) } else { console.log('no user found... ' + JSON.stringify(user)); res.status(401).end('Username or password incorrect'); } });
Make sure your hashed Joomla password is in your Mongo Db; from your Joomla app you need a call to do that job. In php a curl job can do that job.
4Joomla uses bcrypt to hash its passwords so you need a node package for that.In There's several and I only succeeded with bcryptjs ;
Now you need to make the authentication mechanism in your Node app that checks against the db. This is Mongoose talking to Mongo. I'll show the snippet where bcrypt makes the comparison.
function authenticate(req, res, next)
{
var body = req.body;
User.find({username: body.username}, function (err, theuser)
{
if (theuser.length == 1)
{
bcrypt.compare(body.password, theuser[0].password, function (err, ismatch)
{
if(ismatch)
{
user = {joomlaid:theuser[0].joomlaid,username:theuser[0].username, name:theuser[0].name, useremail:theuser[0].useremail};
console.log('found user: ' + JSON.stringify(user));
next();
}
else
{
console.log("user found but no matching passwords" + ismatch);
res.status(401).end('Password incorrect');
}
})
}
else
{
console.log('no user found... ' + JSON.stringify(user));
res.status(401).end('Username or password incorrect');
}
});
In the struggle to make this I made use of an online bcrypt (de)coder;coder