I am working on Registration and Login system in Nodejs and Android based on this tutorial:
https://www.learn2crack.com/2016/09/android-user-registration-login-node-server.html
https://www.learn2crack.com/2016/09/android-user-registration-login-node-client.html
It works fine, however I want to create a system in which user stays logged in- automatic login everytime he turns on the app. At the moment the logging in is based on token created with 'jsonwebtoken' and it works only if user gives email and password:
router.post('/authenticate', (req, res) => {
const credentials = auth(req);
if (!credentials) {
res.status(400).json({ message: 'Invalid Request !' });
} else {
login.loginUser(credentials.name, credentials.pass)
.then(result => {
const token = jwt.sign(result, config.secret, { expiresIn: 1440 });
res.status(result.status).json({ message: result.message, token: token });
})
.catch(err => res.status(err.status).json({ message: err.message }));
}
});
I couldn't find anything specific how to solve it. Could anyone tell me what is the best way to do it and support me with a link or tutorial?