Fix: Todo Multi refresh ...
fix some promises problem
This commit is contained in:
@@ -18,8 +18,8 @@ var { authenticate } = require('../middleware/authenticate');
|
||||
var mongoose = require('mongoose');
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
function existSubScribe(userId, access) {
|
||||
return Subscription.findOne({ userId, access })
|
||||
function existSubScribe(userId, access, browser) {
|
||||
return Subscription.findOne({ userId, access, browser })
|
||||
.then(itemsub => {
|
||||
return itemsub
|
||||
})
|
||||
@@ -126,11 +126,11 @@ router.post('/login', (req, res) => {
|
||||
|
||||
})
|
||||
.then((myris) => {
|
||||
const useragent = req.get('User-Agent');
|
||||
const access = 'auth ' + useragent;
|
||||
const access = 'auth';
|
||||
const browser = req.get('User-Agent');
|
||||
|
||||
// Check if already exist Subscribe
|
||||
return existSubScribe(myris.usertosend.userId, access).then(subscribe => {
|
||||
return existSubScribe(myris.usertosend.userId, access, browser).then(subscribe => {
|
||||
return (subscribe !== null)
|
||||
}).then(subsExistonDb => {
|
||||
return { usertosend: myris.usertosend, token: myris.token, subsExistonDb }
|
||||
|
||||
Reference in New Issue
Block a user