log things the log4js-way; put all the brackets on a new line

This commit is contained in:
mluto 2013-03-30 20:46:56 +01:00
parent 253a8e37fd
commit 7e3b288afc
1 changed files with 17 additions and 10 deletions

View File

@ -27,6 +27,8 @@ var padManager = require("./PadManager");
var sessionManager = require("./SessionManager"); var sessionManager = require("./SessionManager");
var settings = require("../utils/Settings"); var settings = require("../utils/Settings");
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
var log4js = require('log4js');
var authLogger = log4js.getLogger("auth");
/** /**
* This function controlls the access to a pad, it checks if the user can access a pad. * This function controlls the access to a pad, it checks if the user can access a pad.
@ -117,14 +119,17 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
//get information about all sessions contained in this cookie //get information about all sessions contained in this cookie
function(callback) function(callback)
{ {
if (!sessionCookie) { if (!sessionCookie)
{
callback(); callback();
return; return;
} }
var sessionIDs = sessionCookie.split(','); var sessionIDs = sessionCookie.split(',');
async.forEach(sessionIDs, function(sessionID, callback) { async.forEach(sessionIDs, function(sessionID, callback)
sessionManager.getSessionInfo(sessionID, function(err, sessionInfo) { {
sessionManager.getSessionInfo(sessionID, function(err, sessionInfo)
{
//skip session if it doesn't exist //skip session if it doesn't exist
if(err && err.message == "sessionID does not exist") return; if(err && err.message == "sessionID does not exist") return;
@ -133,15 +138,17 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
var now = Math.floor(new Date().getTime()/1000); var now = Math.floor(new Date().getTime()/1000);
//is it for this group? //is it for this group?
if(sessionInfo.groupID != groupID) { if(sessionInfo.groupID != groupID)
console.debug("Auth failed: wrong group"); {
authLogger.debug("Auth failed: wrong group");
callback(); callback();
return; return;
} }
//is validUntil still ok? //is validUntil still ok?
if(sessionInfo.validUntil <= now){ if(sessionInfo.validUntil <= now)
console.debug("Auth failed: validUntil"); {
authLogger.debug("Auth failed: validUntil");
callback(); callback();
return; return;
} }
@ -238,7 +245,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
//--> deny access if user isn't allowed to create the pad //--> deny access if user isn't allowed to create the pad
if(settings.editOnly) if(settings.editOnly)
{ {
console.debug("Auth failed: valid session & pad does not exist"); authLogger.debug("Auth failed: valid session & pad does not exist");
statusObject.accessStatus = "deny"; statusObject.accessStatus = "deny";
} }
} }
@ -272,7 +279,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
//- its not public //- its not public
else if(!isPublic) else if(!isPublic)
{ {
console.debug("Auth failed: invalid session & pad is not public"); authLogger.debug("Auth failed: invalid session & pad is not public");
//--> deny access //--> deny access
statusObject = {accessStatus: "deny"}; statusObject = {accessStatus: "deny"};
} }
@ -284,7 +291,7 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
// there is no valid session avaiable AND pad doesn't exists // there is no valid session avaiable AND pad doesn't exists
else else
{ {
console.debug("Auth failed: invalid session & pad does not exist"); authLogger.debug("Auth failed: invalid session & pad does not exist");
//--> deny access //--> deny access
statusObject = {accessStatus: "deny"}; statusObject = {accessStatus: "deny"};
} }