I made a work around to fix my problem.
I changed the hard-coded message to a just return a code, then on the dust, I displayed the appropriate message depending on the code passed from the controller.
Here's the code on the controller.
return new LocalStrategy({
passReqToCallback: true
}, function (req, username, password, done) {
OUR_API.login({
username: username,
password: password
}).then(function (accessToken) {
return done(null, {
username: username,
accessToken: accessToken
});
}, function (err) {
var errCode;
if (err && err.message && err.message.error) {
errCode = err.message.error.code.toString();
}
return done(null, false, errCode);
});
});
then on the dust page.
{?errorCode}
{@select key="{errorCode}"}
{@eq value="0001"}{@pre type="content" key="error.message.0001"/}{/eq}
{@eq value="0002"}{@pre type="content" key="error.message.0002"/}{/eq}
{@default}{@pre type="content" key="error.message.default"/}{/default}
{/select}
{/errorCode}
Hope this helps anyone having same problem as mine. Or anyone has better ideas?