handle no token in a productive way
This commit is contained in:
parent
9cd82b4b74
commit
a3e9d1a9f0
|
@ -27,7 +27,15 @@ function sendResponse(json, resp) {
|
||||||
function validUser(token, res, cb) {
|
function validUser(token, res, cb) {
|
||||||
return new Promise(function(resolve, rej) {
|
return new Promise(function(resolve, rej) {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return resolve(false);
|
console.error('lib.dialect::validUser - getUserClientByToken - no token', token);
|
||||||
|
const resObj={
|
||||||
|
meta: {
|
||||||
|
code: 401,
|
||||||
|
error_message: 'Authorization required'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sendResponse(resObj, res);
|
||||||
|
return resolve();
|
||||||
}
|
}
|
||||||
dispatcher.getUserClientByToken(token, (err, usertoken) => {
|
dispatcher.getUserClientByToken(token, (err, usertoken) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -38,10 +46,10 @@ function validUser(token, res, cb) {
|
||||||
error_message: err
|
error_message: err
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
console.error('lib.dialect::validUser - error trying to verify token:', token);
|
|
||||||
sendResponse(resObj, res);
|
sendResponse(resObj, res);
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
//console.log('lib.dialect::validUser - usertoken', JSON.parse(JSON.stringify(usertoken)))
|
||||||
if (usertoken === null) {
|
if (usertoken === null) {
|
||||||
// could be they didn't log in through a server restart
|
// could be they didn't log in through a server restart
|
||||||
const resObj={
|
const resObj={
|
||||||
|
|
Loading…
Reference in New Issue