no message
This commit is contained in:
@@ -6,7 +6,7 @@ var options = {
|
||||
// Optional depending on the providers
|
||||
httpAdapter: 'https', // Default
|
||||
apiKey: 'AIzaSyCvpBGztvxtRUNigOW9f0GXVRWlukJZsps', // for Mapquest, OpenCage, Google Premier
|
||||
formatter: null // 'gpx', 'string', ...
|
||||
formatter: null // 'gpx', 'string', ...
|
||||
};
|
||||
|
||||
var geocoder = NodeGeocoder(options);
|
||||
|
||||
22
modules/logger.js
Normal file
22
modules/logger.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const winston = require('winston');
|
||||
|
||||
var logger = new (winston.Logger)({
|
||||
transports: [
|
||||
new (winston.transports.File)({
|
||||
name: 'debug-file',
|
||||
filename: 'urge-debug.log',
|
||||
handleExceptions: true,
|
||||
humanReadableUnhandledException: true,
|
||||
level: 'debug'
|
||||
}),
|
||||
new (winston.transports.File)({
|
||||
name: 'error-file',
|
||||
filename: 'urge-error.log',
|
||||
handleExceptions: true,
|
||||
humanReadableUnhandledException: true,
|
||||
level: 'error'
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = logger;
|
||||
@@ -12,6 +12,8 @@ const Token = {
|
||||
}
|
||||
};
|
||||
|
||||
var logger = require('../modules/logger');
|
||||
|
||||
function createAnonymousToken (e) {
|
||||
Token.create({ user: null, permission: 0 }, (err, token) => {
|
||||
if (err) {
|
||||
@@ -105,20 +107,17 @@ function verifyTokenAndUserThen (token, minimumPermission, callback) {
|
||||
}
|
||||
|
||||
function verifyTokenAndRoleThen (token, action, callback, log = false) {
|
||||
if (log) console.log('verifyTokenAndRoleThen', { token: token, action: action });
|
||||
logger.debug('verifyTokenAndRoleThen', { token: token, action: action });
|
||||
validateToken(null, token, (err, decoded) => {
|
||||
if (log) console.log('verifyTokenAndRoleThen::validateToken', { err: err, decoded: decoded.data });
|
||||
logger.debug('verifyTokenAndRoleThen::validateToken', { err: err, decoded: decoded.data });
|
||||
|
||||
if (err) {
|
||||
callback('Session could not be validated.', null);
|
||||
}
|
||||
|
||||
let [initial, canElevateTo = false] = Array.isArray(action) ? action : [ action ];
|
||||
|
||||
if (log) {
|
||||
console.log('Roles.canRole[' + initial + ']', Roles.canRole(null, decoded.data.permission, initial));
|
||||
console.log('Roles.canRole[' + canElevateTo + ']', Roles.canRole(null, decoded.data.permission, canElevateTo));
|
||||
}
|
||||
let [initial, canElevateTo = false] = Array.isArray(action) ? action : [ action ];
|
||||
logger.debug('Roles.canRole[' + initial + ']', Roles.canRole(null, decoded.data.permission, initial));
|
||||
logger.debug('Roles.canRole[' + canElevateTo + ']', Roles.canRole(null, decoded.data.permission, canElevateTo));
|
||||
|
||||
if (decoded && decoded.valid) {
|
||||
Roles.canRole(null, decoded.data.permission, action, (err, result) => {
|
||||
|
||||
Reference in New Issue
Block a user