More ESLint fixes

pull/2654/head
Rodrigo Nascimento 9 years ago
parent 3d0660ecbe
commit c95a64ab8c
  1. 1
      .eslintignore
  2. 16
      .eslintrc.js
  3. 43
      packages/meteor-accounts-saml/saml_client.js
  4. 89
      packages/meteor-accounts-saml/saml_server.js
  5. 2
      packages/meteor-accounts-saml/saml_utils.js
  6. 43
      packages/rocketchat-cas/cas_client.js
  7. 118
      packages/rocketchat-cas/cas_server.js
  8. 8
      packages/rocketchat-emojione/emojiPicker.js
  9. 1
      packages/rocketchat-file-upload/client/lib/fileUploadHandler.js
  10. 5
      packages/rocketchat-file-upload/lib/FileUpload.js
  11. 1
      packages/rocketchat-file-upload/lib/FileUploadBase.js
  12. 4
      packages/rocketchat-file-upload/server/methods/sendFileMessage.js
  13. 1
      packages/rocketchat-integrations/server/logger.js
  14. 2
      packages/rocketchat-katex/package.js
  15. 1
      packages/rocketchat-ldap/server/ldap.js
  16. 2
      packages/rocketchat-ldap/server/sync.js
  17. 32
      packages/rocketchat-livechat/app/client/lib/triggers.js
  18. 29
      packages/rocketchat-livechat/assets/rocket-livechat.js
  19. 2
      packages/rocketchat-ui-message/message/renderMessageBody.js

@ -15,5 +15,6 @@ packages/rocketchat-ui/lib/particles.js
packages/rocketchat-ui/lib/recorderjs/recorder.js
packages/rocketchat-ui/lib/textarea-autogrow.js
packages/rocketchat-ui/lib/customEventPolyfill.js
packages/rocketchat-ui/lib/constallation.js
packages/rocketchat-livechat/client/lib/ua-parser.js
packages/rocketchat-livechat/public/livechat.js

@ -101,7 +101,11 @@ module.exports = {
'no-regex-spaces': 2, // disallow multiple spaces in a regular expression literal
'no-undef': 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
'no-unreachable': 2, // disallow unreachable statements after a return, throw, continue, or break statement
'no-unused-vars': [2, {'vars': 'all', 'args': 'after-used'}], // disallow declaration of variables that are not used in the code
'no-unused-vars': [2, { // disallow declaration of variables that are not used in the code
'vars': 'all',
'args': 'after-used',
'varsIgnorePattern': 'RocketChat'
}],
// 'array-bracket-spacing': [0, 'never'],
// 'arrow-parens': 0,
@ -167,7 +171,15 @@ module.exports = {
'block-scoped-var': 2, // treat var statements as if they were block scoped
'curly': [2, 'all'], // specify curly brace conventions for all control statements
'eqeqeq': [2, 'allow-null'], // require use of === and !==
'new-cap': 2, // require a capital letter for constructors
'new-cap': [2, { // require a capital letter for constructors
'capIsNewExceptions': [
'SHA256',
'Match.ObjectIncluding',
'Match.Optional',
'Match.Optional',
'Match.ObjectIncluding'
]
}],
'use-isnan': 2, // disallow comparisons with the value NaN
'valid-typeof': 2, // ensure results of typeof are compared against a valid string
'linebreak-style': [2, 'unix'], // enforce linebreak style

@ -2,6 +2,27 @@ if (!Accounts.saml) {
Accounts.saml = {};
}
var openCenteredPopup = function (url, width, height) {
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft;
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop;
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth;
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22);
// XXX what is the 22?
// Use `outerWidth - width` and `outerHeight - height` for help in
// positioning the popup centered relative to the current window
var left = screenX + (outerWidth - width) / 2;
var top = screenY + (outerHeight - height) / 2;
var features = ('width=' + width + ',height=' + height +
',left=' + left + ',top=' + top + ',scrollbars=yes');
var newwindow = window.open(url, 'Login', features);
if (newwindow.focus) {
newwindow.focus();
}
return newwindow;
};
Accounts.saml.initiateLogin = function (options, callback, dimensions) {
// default dimensions that worked well for facebook and google
var popup = openCenteredPopup(
@ -29,28 +50,6 @@ Accounts.saml.initiateLogin = function (options, callback, dimensions) {
}, 100);
};
var openCenteredPopup = function (url, width, height) {
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft;
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop;
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth;
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22);
// XXX what is the 22?
// Use `outerWidth - width` and `outerHeight - height` for help in
// positioning the popup centered relative to the current window
var left = screenX + (outerWidth - width) / 2;
var top = screenY + (outerHeight - height) / 2;
var features = ('width=' + width + ',height=' + height +
',left=' + left + ',top=' + top + ',scrollbars=yes');
var newwindow = window.open(url, 'Login', features);
if (newwindow.focus) {
newwindow.focus();
}
return newwindow;
};
Meteor.loginWithSaml = function (options, callback) {
options = options || {};
var credentialToken = Random.id();

@ -11,7 +11,7 @@ if (!Accounts.saml) {
};
}
var Fiber = Npm.require('fibers');
var fiber = Npm.require('fibers');
var connect = Npm.require('connect');
RoutePolicy.declare('/_saml/', 'network');
@ -166,15 +166,41 @@ Accounts.saml.retrieveCredential = function (credentialToken) {
return result;
};
var closePopup = function (res, err) {
res.writeHead(200, {
'Content-Type': 'text/html'
});
var content = '<html><head><script>window.close()</script></head><body><H1>Verified</H1></body></html>';
if (err) {
content = '<html><body><h2>Sorry, an annoying error occured</h2><div>' + err + '</div><a onclick="window.close();">Close Window</a></body></html>';
}
res.end(content, 'utf-8');
};
// Listen to incoming SAML http requests
WebApp.connectHandlers.use(connect.bodyParser()).use(function (req, res, next) {
// Need to create a Fiber since we're using synchronous http calls and nothing
// else is wrapping this in a fiber automatically
Fiber(function () {
middleware(req, res, next);
}).run();
});
var samlUrlToObject = function (url) {
// req.url will be '/_saml/<action>/<service name>/<credentialToken>'
if (!url) {
return null;
}
var splitPath = url.split('/');
// Any non-saml request will continue down the default
// middlewares.
if (splitPath[1] !== '_saml') {
return null;
}
var result = {
actionName: splitPath[2],
serviceName: splitPath[3],
credentialToken: splitPath[4]
};
if (Accounts.saml.settings.debug) {
console.log(result);
}
return result;
};
var middleware = function (req, res, next) {
// Make sure to catch any exceptions because otherwise we'd crash
@ -245,7 +271,7 @@ var middleware = function (req, res, next) {
}
};
Fiber(function () {
fiber(function () {
logOutUser(result);
}).run();
@ -309,38 +335,11 @@ var middleware = function (req, res, next) {
}
};
var samlUrlToObject = function (url) {
// req.url will be '/_saml/<action>/<service name>/<credentialToken>'
if (!url) {
return null;
}
var splitPath = url.split('/');
// Any non-saml request will continue down the default
// middlewares.
if (splitPath[1] !== '_saml') {
return null;
}
var result = {
actionName: splitPath[2],
serviceName: splitPath[3],
credentialToken: splitPath[4]
};
if (Accounts.saml.settings.debug) {
console.log(result);
}
return result;
};
var closePopup = function (res, err) {
res.writeHead(200, {
'Content-Type': 'text/html'
});
var content = '<html><head><script>window.close()</script></head><body><H1>Verified</H1></body></html>';
if (err) {
content = '<html><body><h2>Sorry, an annoying error occured</h2><div>' + err + '</div><a onclick="window.close();">Close Window</a></body></html>';
}
res.end(content, 'utf-8');
};
// Listen to incoming SAML http requests
WebApp.connectHandlers.use(connect.bodyParser()).use(function (req, res, next) {
// Need to create a fiber since we're using synchronous http calls and nothing
// else is wrapping this in a fiber automatically
fiber(function () {
middleware(req, res, next);
}).run();
});

@ -146,7 +146,6 @@ SAML.prototype.generateLogoutRequest = function (options) {
SAML.prototype.requestToUrl = function (request, operation, callback) {
var self = this;
var result;
zlib.deflateRaw(request, function (err, buffer) {
if (err) {
return callback(err);
@ -191,7 +190,6 @@ SAML.prototype.requestToUrl = function (request, operation, callback) {
}
if (operation === 'logout') {
// in case of logout we want to be redirected back to the Meteor app.
result = target;
return callback(null, target);
} else {

@ -1,3 +1,24 @@
var openCenteredPopup = function(url, width, height) {
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft;
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop;
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth;
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22);
// XXX what is the 22?
// Use `outerWidth - width` and `outerHeight - height` for help in
// positioning the popup centered relative to the current window
var left = screenX + (outerWidth - width) / 2;
var top = screenY + (outerHeight - height) / 2;
var features = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=yes');
var newwindow = window.open(url, 'Login', features);
if (newwindow.focus) {
newwindow.focus();
}
return newwindow;
};
Meteor.loginWithCas = function(callback) {
@ -44,25 +65,3 @@ Meteor.loginWithCas = function(callback) {
}
}, 100);
};
var openCenteredPopup = function(url, width, height) {
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft;
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop;
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth;
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22);
// XXX what is the 22?
// Use `outerWidth - width` and `outerHeight - height` for help in
// positioning the popup centered relative to the current window
var left = screenX + (outerWidth - width) / 2;
var top = screenY + (outerHeight - height) / 2;
var features = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=yes');
var newwindow = window.open(url, 'Login', features);
if (newwindow.focus) {
newwindow.focus();
}
return newwindow;
};

@ -1,7 +1,7 @@
/* globals RoutePolicy, logger */
/* jshint newcap: false */
var Fiber = Npm.require('fibers');
var fiber = Npm.require('fibers');
var url = Npm.require('url');
var CAS = Npm.require('cas');
@ -9,45 +9,10 @@ var _casCredentialTokens = {};
RoutePolicy.declare('/_cas/', 'network');
// Listen to incoming OAuth http requests
WebApp.connectHandlers.use(function(req, res, next) {
// Need to create a Fiber since we're using synchronous http calls and nothing
// else is wrapping this in a fiber automatically
Fiber(function () {
middleware(req, res, next);
}).run();
});
var middleware = function (req, res, next) {
// Make sure to catch any exceptions because otherwise we'd crash
// the runner
try {
var barePath = req.url.substring(0, req.url.indexOf('?'));
var splitPath = barePath.split('/');
// Any non-cas request will continue down the default
// middlewares.
if (splitPath[1] !== '_cas') {
next();
return;
}
// get auth token
var credentialToken = splitPath[2];
if (!credentialToken) {
closePopup(res);
return;
}
// validate ticket
casTicket(req, credentialToken, function() {
closePopup(res);
});
} catch (err) {
logger.error('Unexpected error : ' + err.message);
closePopup(res);
}
var closePopup = function(res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var content = '<html><head><script>window.close()</script></head></html>';
res.end(content, 'utf-8');
};
var casTicket = function (req, token, callback) {
@ -87,6 +52,60 @@ var casTicket = function (req, token, callback) {
return;
};
var middleware = function (req, res, next) {
// Make sure to catch any exceptions because otherwise we'd crash
// the runner
try {
var barePath = req.url.substring(0, req.url.indexOf('?'));
var splitPath = barePath.split('/');
// Any non-cas request will continue down the default
// middlewares.
if (splitPath[1] !== '_cas') {
next();
return;
}
// get auth token
var credentialToken = splitPath[2];
if (!credentialToken) {
closePopup(res);
return;
}
// validate ticket
casTicket(req, credentialToken, function() {
closePopup(res);
});
} catch (err) {
logger.error('Unexpected error : ' + err.message);
closePopup(res);
}
};
// Listen to incoming OAuth http requests
WebApp.connectHandlers.use(function(req, res, next) {
// Need to create a fiber since we're using synchronous http calls and nothing
// else is wrapping this in a fiber automatically
fiber(function () {
middleware(req, res, next);
}).run();
});
var _hasCredential = function(credentialToken) {
return _.has(_casCredentialTokens, credentialToken);
};
/*
* Retrieve token and delete it to avoid replaying it.
*/
var _retrieveCredential = function(credentialToken) {
var result = _casCredentialTokens[credentialToken];
delete _casCredentialTokens[credentialToken];
return result;
};
/*
* Register a server-side login handle.
* It is call after Accounts.callLoginMethod() is call from client.
@ -143,22 +162,3 @@ Accounts.registerLoginHandler(function (options) {
return { userId: user._id };
});
var _hasCredential = function(credentialToken) {
return _.has(_casCredentialTokens, credentialToken);
};
/*
* Retrieve token and delete it to avoid replaying it.
*/
var _retrieveCredential = function(credentialToken) {
var result = _casCredentialTokens[credentialToken];
delete _casCredentialTokens[credentialToken];
return result;
};
var closePopup = function(res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var content = '<html><head><script>window.close()</script></head></html>';
res.end(content, 'utf-8');
};

@ -1,4 +1,8 @@
/* globals Template, emojione */
var emojisByCategory;
var toneList;
Template.emojiPicker.helpers({
category() {
return Object.keys(emojisByCategory);
@ -112,7 +116,7 @@ Template.emojiPicker.onCreated(function() {
};
});
var toneList = {
toneList = {
'raised_hands': 1,
'clap': 1,
'wave': 1,
@ -180,7 +184,7 @@ var toneList = {
'spy': 1
};
var emojisByCategory = {
emojisByCategory = {
'recent': [],
'symbols': [
'100',

@ -1,4 +1,5 @@
/* globals FileUpload, fileUploadHandler:true */
/* exported fileUploadHandler */
fileUploadHandler = (meta, file, data) => {
var storageType = RocketChat.settings.get('FileUpload_Storage_Type');

@ -1,4 +1,8 @@
/* globals FileUpload:true */
/* exported FileUpload */
var maxFileSize = 0;
FileUpload = {
validateFileUpload(file) {
if (file.size > maxFileSize) {
@ -13,7 +17,6 @@ FileUpload = {
}
};
var maxFileSize = 0;
RocketChat.settings.get('FileUpload_MaxFileSize', function(key, value) {
maxFileSize = value;
});

@ -1,4 +1,5 @@
/* globals FileUploadBase:true */
/* exported FileUploadBase */
FileUploadBase = class FileUploadBase {
constructor(meta, file/*, data*/) {

@ -37,7 +37,7 @@ Meteor.methods({
attachment.video_size = file.size;
}
msg = {
var msg = {
_id: Random.id(),
rid: roomId,
msg: '',
@ -48,6 +48,6 @@ Meteor.methods({
attachments: [attachment]
};
var msg = Meteor.call('sendMessage', msg);
msg = Meteor.call('sendMessage', msg);
}
});

@ -1,4 +1,5 @@
/* globals logger:true */
/* exported logger */
logger = new Logger('Integrations', {
sections: {

@ -23,7 +23,7 @@ Package.onUse(function(api) {
var _ = Npm.require('underscore');
var fs = Npm.require('fs');
var fontFiles = _.map(fs.readdirSync('packages/rocketchat-katex/client/fonts'), function(filename) {
return 'client/fonts/' + filename;
return 'client/fonts/' + filename;
});
api.addAssets(fontFiles, 'client');

@ -1,4 +1,5 @@
/* globals LDAP:true, LDAPJS */
/* exported LDAP */
const ldapjs = LDAPJS;

@ -1,4 +1,4 @@
/* globals slug:true, slugify, LDAP, getLdapUsername:true, getLdapUserUniqueID:true, getDataToSyncUserData:true, syncUserData:true, sync:true, */
/* globals slug:true, slugify, LDAP, getLdapUsername:true, getLdapUserUniqueID:true, getDataToSyncUserData:true, syncUserData:true, sync:true */
const logger = new Logger('LDAPSync', {});

@ -3,21 +3,6 @@ this.Triggers = (function() {
var initiated = false;
var requests = [];
var init = function() {
initiated = true;
Tracker.autorun(function() {
triggers = Trigger.find().fetch();
if (requests.length > 0 && triggers.length > 0) {
requests.forEach(function(request) {
processRequest(request);
});
requests = [];
}
});
};
var fire = function(actions) {
if (Meteor.userId()) {
console.log('already logged user - does nothing');
@ -72,8 +57,23 @@ this.Triggers = (function() {
});
};
var init = function() {
initiated = true;
Tracker.autorun(function() {
triggers = Trigger.find().fetch();
if (requests.length > 0 && triggers.length > 0) {
requests.forEach(function(request) {
processRequest(request);
});
requests = [];
}
});
};
return {
init: init,
processRequest: processRequest
};
})();
}());

@ -8,6 +8,7 @@
// h.parentNode.insertBefore(j, h);
// })(window, document, 'script', 'initRocket', 'http://localhost:5000/livechat');
// </script>
/* globals RocketChat:true */
/* exported RocketChat */
var RocketChat = (function(w) {
@ -27,6 +28,19 @@ var RocketChat = (function(w) {
widget.style.height = '300px';
};
// hooks
var callHook = function(action, params) {
if (!ready) {
return hookQueue.push(arguments);
}
var data = {
src: 'rocketchat',
fn: action,
args: params
};
iframe.contentWindow.postMessage(data, '*');
};
var api = {
ready: function() {
ready = true;
@ -57,19 +71,6 @@ var RocketChat = (function(w) {
}
};
// hooks
var callHook = function(action, params) {
if (!ready) {
return hookQueue.push(arguments);
}
var data = {
src: 'rocketchat',
fn: action,
args: params
};
iframe.contentWindow.postMessage(data, '*');
};
var pageVisited = function() {
callHook('pageVisited', {
location: JSON.parse(JSON.stringify(document.location)),
@ -165,4 +166,4 @@ var RocketChat = (function(w) {
return {
pageVisited: pageVisited
};
})(window);
}(window));

@ -1,4 +1,6 @@
/* global renderMessageBody:true */
/* exported renderMessageBody */
renderMessageBody = function(msg) {
var message;

Loading…
Cancel
Save