Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.login = function (req, res, next) {
- Admin.getUserByLogin(req.user.email, (err, user) => {
- if (err) {
- res.json(err);
- }
- //console.log(user.salt, user.hashedPassword);
- //res.json(user);
- console.log(req.user._id);
- if (cryptPassword(user.salt, req.body.password) === user.hashedPassword) {
- var randomstring = Math.random().toString(36).slice(-4);
- queues.getQueue('sms').sendMessage('test', {
- token: randomstring,
- userId: req.user._id
- });
- res.json({"token": randomstring});
- }
- })
- function cryptPassword(salt, password) {
- if (!password) {
- throw new errors.NotAcceptable('$password must be specified');
- }
- return crypto.createHmac('sha1', salt).update(password).digest('hex');
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement