Show data Table with pagination (startRow, endRow, filter, sorting)
This commit is contained in:
@@ -40,6 +40,7 @@ router.post('/', (req, res) => {
|
||||
|
||||
user.linkreg = reg.getlinkregByEmail(body.idapp, body.email, body.username);
|
||||
user.verified_email = false;
|
||||
user.ipaddr = reg.getiPAddressUser(req);
|
||||
if (tools.testing()) {
|
||||
user.verified_email = true;
|
||||
}
|
||||
@@ -95,7 +96,7 @@ router.patch('/:id', authenticate, (req, res) => {
|
||||
|
||||
if (!User.isAdmin(req.user)) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).send();
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
|
||||
}
|
||||
|
||||
User.findByIdAndUpdate(id, { $set: body }).then((user) => {
|
||||
@@ -147,6 +148,10 @@ router.post('/login', (req, res) => {
|
||||
usertosend.userId = user._id.toHexString();
|
||||
usertosend.verified_email = user.verified_email;
|
||||
usertosend.idapp = user.idapp;
|
||||
usertosend.perm = user.perm;
|
||||
if (!User.isAdmin(req.user)) {
|
||||
usertosend.ipaddr = user.ipaddr;
|
||||
}
|
||||
|
||||
// tools.mylog("user.verified_email:" + user.verified_email);
|
||||
tools.mylog("usertosend.userId", usertosend.userId);
|
||||
@@ -155,32 +160,32 @@ router.post('/login', (req, res) => {
|
||||
// tools.mylog(usertosend);
|
||||
return { usertosend, token }
|
||||
|
||||
})
|
||||
.then((myris) => {
|
||||
const access = 'auth';
|
||||
const browser = req.get('User-Agent');
|
||||
})
|
||||
.then((myris) => {
|
||||
const access = 'auth';
|
||||
const browser = req.get('User-Agent');
|
||||
|
||||
// Check if already exist Subscribe
|
||||
return existSubScribe(myris.usertosend.userId, access, browser).then(subscribe => {
|
||||
return (subscribe !== null)
|
||||
}).then(subsExistonDb => {
|
||||
return { usertosend: myris.usertosend, token: myris.token, subsExistonDb }
|
||||
}).catch(err => {
|
||||
return { usertosend: myris.usertosend, token: myris.token, subsExistonDb:false }
|
||||
})
|
||||
}).then(myris => {
|
||||
console.log('res', myris.token, myris.usertosend);
|
||||
// Check if already exist Subscribe
|
||||
return existSubScribe(myris.usertosend.userId, access, browser).then(subscribe => {
|
||||
return (subscribe !== null)
|
||||
}).then(subsExistonDb => {
|
||||
return { usertosend: myris.usertosend, token: myris.token, subsExistonDb }
|
||||
}).catch(err => {
|
||||
return { usertosend: myris.usertosend, token: myris.token, subsExistonDb: false }
|
||||
})
|
||||
}).then(myris => {
|
||||
console.log('res', myris.token, myris.usertosend);
|
||||
|
||||
// SEND TOKEN AND CODE RESULT
|
||||
res.header('x-auth', myris.token).send({
|
||||
usertosend: myris.usertosend,
|
||||
code: server_constants.RIS_CODE_OK,
|
||||
subsExistonDb: myris.subsExistonDb
|
||||
// SEND TOKEN AND CODE RESULT
|
||||
res.header('x-auth', myris.token).send({
|
||||
usertosend: myris.usertosend,
|
||||
code: server_constants.RIS_CODE_OK,
|
||||
subsExistonDb: myris.subsExistonDb
|
||||
});
|
||||
// tools.mylog("TROVATOOO!");
|
||||
|
||||
tools.mylog('FINE LOGIN')
|
||||
});
|
||||
// tools.mylog("TROVATOOO!");
|
||||
|
||||
tools.mylog('FINE LOGIN')
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
@@ -210,4 +215,5 @@ router.post('/setperm', authenticate, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user