Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.post('/login', (req, res) => {
- // hash the password
- hash(req.password, (err, hashedPassword) => {
- if (err) {
- throw new Error(err.message);
- }
- // find combination of username and password in db
- User.find({ username: req.username, password: hashedPassword }, (err, user) => {
- if (err) {
- throw new Error(err.message);
- }
- // save session to redis
- redis.hget(user.id, (err, session) => {
- if (err) {
- throw new Error(err.message);
- }
- // load user information after session is succesfully saved
- Transaction.find({ userId: user.id }, (err, transaction) => {
- return transaction;
- });
- });
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement