Created
July 29, 2021 14:37
-
-
Save walidum/7163f8a232513a432af5e7ccb865b173 to your computer and use it in GitHub Desktop.
login.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.login = (req, res) => { | |
const registrationdata = { | |
userName: req.body.UserName, | |
password: req.body.Password | |
}; | |
if (req.body.UserName && req.body.Password) { | |
const config = { | |
headers: {Authorization: `DirectLogin username="${req.body.UserName}", password="${req.body.Password}", consumer_key="b2yn2ma5fqegtlgghvdpq0unlj5xdrja5wwoecon"`} | |
}; | |
axios.post('https://ifcsandbox.openbankproject.com/my/logins/direct', | |
{}, | |
config | |
).then(data => { | |
if (!data) { | |
res.status(404).send({message: "Not found user with email " + registrationdata}) | |
} else { | |
// res.send(data) | |
logindetails.username = req.body.UserName; | |
res.redirect('/add-activity'); | |
} | |
}) | |
.catch(err => { | |
res.status(500).send({message: "Erro retrieving user with email " + registrationdata}) | |
}) | |
} else { | |
res.status(500).send({message: "Erro retrieving user with email " + registrationdata}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment