Commit f07ec3bc authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Evita acceso directo a variables globales

parent 2e9af0a9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -43,7 +43,8 @@ define([

			_onLoadReCaptcha = null;

			var siteKey = envProduction === 'true' ? this._siteKey : this._siteKeyForDebug;
			var isProduction = redmicConfig.getEnvVariableValue('envProduction') === 'true',
				siteKey = isProduction ? this._siteKey : this._siteKeyForDebug;

			this._instanceId = grecaptcha.render(this.node, {
				'sitekey': siteKey,
+18 −2
Original line number Diff line number Diff line
@@ -573,23 +573,39 @@ define([], function() {
		return this.outerPaths.indexOf(ancestorPath) !== -1;
	};

	retObj.getEnvVariableValue = function(variableName) {

		var variableValue;

		try {
			variableValue = eval(variableName);
		} catch(e) {
			console.warn('Tried to get undefined global variable "%s"', variableName);
			variableValue = '';
		}

		return variableValue;
	};

	retObj.getServiceUrl = function(serviceName) {

		if (!serviceName || !serviceName.length) {
			return;
		}

		var apiUrl = retObj.getEnvVariableValue('envApiUrl');

		// TODO esto es necesario hasta que todos los lang.replace de rutas se centralicen y se puedan devolver como dfd
		var undefinedIndex = serviceName.indexOf('undefined');
		if (undefinedIndex !== -1) {
			console.error('Service URL "%s" contains "undefined", variable replacement went wrong', serviceName);
			if (undefinedIndex === 0) {
				console.error('Trying to replace "undefined" with API URL..');
				return serviceName.replace('undefined', envApiUrl);
				return serviceName.replace('undefined', apiUrl);
			}
		}

		return serviceName.replace('{apiUrl}', envApiUrl);
		return serviceName.replace('{apiUrl}', apiUrl);
	};

	return retObj;
+21 −20
Original line number Diff line number Diff line
define([
	"dijit/_TemplatedMixin"
	, "dijit/_WidgetBase"
	, "dijit/_WidgetsInTemplateMixin"
	'app/redmicConfig'
	, 'dijit/_TemplatedMixin'
	, 'dijit/_WidgetBase'
	, 'dijit/_WidgetsInTemplateMixin'
	, 'dijit/layout/ContentPane'
	, "dojo/text!./templates/ExternalUserBase.html"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/_base/kernel"
	, "put-selector/put"
	, 'dojo/text!./templates/ExternalUserBase.html'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/_base/kernel'
	, 'redmic/modules/base/_Module'
	, 'redmic/modules/base/_Show'

	, "dijit/form/Form"
	, "dijit/form/ValidationTextBox"
	, "dijit/form/Button"
	, 'dijit/form/Form'
	, 'dijit/form/ValidationTextBox'
	, 'dijit/form/Button'
], function(
	_TemplatedMixin
	redmicConfig
	, _TemplatedMixin
	, _WidgetBase
	, _WidgetsInTemplateMixin
	, ContentPane
@@ -23,10 +24,10 @@ define([
	, declare
	, lang
	, kernel
	, put
	, _Module
	, _Show
) {

	return declare([_Module, _Show, ContentPane], {
		//	Summary:
		//		Vista base de aplicación externa
@@ -49,9 +50,9 @@ define([
					_getManagerNode: this._getManagerNode,
					_changeLang: this._changeLang
				},
				baseClass: "",
				baseClass: '',
				replaceReg: /\%\[([^\]]+)\]/g,
				whatIsRedmicPath: "what-is-redmic"
				whatIsRedmicPath: 'what-is-redmic'
			};

			lang.mixin(this, this.config, args);
@@ -78,14 +79,14 @@ define([
		_showVersion: function() {

			if (this.template.versionNumber) {
				this.template.versionNumber.innerHTML = envVersion;
				this.template.versionNumber.innerHTML = redmicConfig.getEnvVariableValue('envVersion');
			}
		},

		_changeLang: function(evt) {

			window.location.href = window.location.protocol + "//" + evt.target.dataset.dojoProps + "." +
				window.location.hostname.replace(kernel.locale + ".", "");
			window.location.href = window.location.protocol + '//' + evt.target.dataset.dojoProps + '.' +
				window.location.hostname.replace(kernel.locale + '.', '');
		},

		_onShowWhatIsRedmic: function(event) {
@@ -98,7 +99,7 @@ define([
			//

			event.stopPropagation();
			var path = "what-is-redmic";
			var path = 'what-is-redmic';
			if (window.location.href.indexOf(path) < 0) {
				window.location.href = path;
			} else {
+38 −36
Original line number Diff line number Diff line
define([
	"dijit/form/Button"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/topic"
	, "put-selector/put"
	, "redmic/base/Credentials"
	, "redmic/modules/base/_Module"
	, "redmic/modules/base/_Show"
	'app/redmicConfig'
	, 'dijit/form/Button'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/topic'
	, 'put-selector/put'
	, 'redmic/base/Credentials'
	, 'redmic/modules/base/_Module'
	, 'redmic/modules/base/_Show'
],
function(
	Button
	redmicConfig
	, Button
	, declare
	, lang
	, topic
@@ -38,19 +40,19 @@ function(
			this.config = {
				// own events
				events: {
					UPLOAD_FILE: "uploadFile",
					DOWNLOAD_FILE: "downloadFile"
					UPLOAD_FILE: 'uploadFile',
					DOWNLOAD_FILE: 'downloadFile'
				},
				// own actions
				actions: {
					UPLOAD_FILE: "uploadFile",
					DOWNLOAD_FILE: "downloadFile"
					UPLOAD_FILE: 'uploadFile',
					DOWNLOAD_FILE: 'downloadFile'
				},
				zones: {
					filter: {
						node: null,
						align: "right",
						"class": "div.btnGroup",
						align: 'right',
						'class': 'div.btnGroup',
						btns: {
							upload: {
								node: null,
@@ -58,10 +60,10 @@ function(
								permission: false,
								props: {
									showLabel: false,
									"class": "primary",
									'class': 'primary',
									label: this.i18n.upload,
									iconClass: "fa-upload",
									action: "_uploadFile"
									iconClass: 'fa-upload',
									action: '_uploadFile'
								}
							},
							download: {
@@ -70,10 +72,10 @@ function(
								permission: true,
								props: {
									showLabel: false,
									"class": "primary",
									'class': 'primary',
									label: this.i18n.createReport,
									iconClass: "fa-print",
									action: "_downloadFile"
									iconClass: 'fa-print',
									action: '_downloadFile'
								}
							}
						}
@@ -81,8 +83,8 @@ function(
				},
				handlers: {},
				perms: {},
				ownChannel: "manager",
				viewSeparator: "/"
				ownChannel: 'manager',
				viewSeparator: '/'
			};

			lang.mixin(this, this.config, args);
@@ -94,7 +96,7 @@ function(

			this.subscriptionsConfig.push({
				channel: this.getParentChannel(),
				callback: "_subChangeView",
				callback: '_subChangeView',
				options: {
					predicate: lang.hitch(this, this._chkChangeView)
				}
@@ -105,24 +107,24 @@ function(

			this.publicationsConfig.push({
				event: 'UPLOAD_FILE',
				channel: this.getChannel("UPLOAD_FILE")
				channel: this.getChannel('UPLOAD_FILE')
			},{
				event: 'DOWNLOAD_FILE',
				channel: this.getChannel("DOWNLOAD_FILE")
				channel: this.getChannel('DOWNLOAD_FILE')
			});
		},

		postCreate: function() {

			this.leftContainer = put(this.domNode, "div.left");
			this.rightContainer = put(this.domNode, "div.right");
			this.leftContainer = put(this.domNode, 'div.left');
			this.rightContainer = put(this.domNode, 'div.right');

			this._checkDomainToAddMessage();
		},

		_checkDomainToAddMessage: function() {

			if (envProduction === 'false') {
			if (redmicConfig.getEnvVariableValue('envProduction') === 'false') {
				this._addMessage('.appDev', this.i18n.messageAppDev);
			}
		},
@@ -140,7 +142,7 @@ function(
			// 	private

			// Eventos procedentes de los módulos
			this.handlers.create = topic.subscribe("/manager/create", lang.hitch(this, this._createManager));
			this.handlers.create = topic.subscribe('/manager/create', lang.hitch(this, this._createManager));
		},

		_findPerms: function(/*String*/ moduleKey) {
@@ -154,7 +156,7 @@ function(
			//		Permisos del módulo si se encuentra, o 0 si no se encuentra

			// Categorías a las que tiene acceso el usuario
			var categories = Credentials.get("allowedModules"),
			var categories = Credentials.get('allowedModules'),
				moduleKeySplitted = moduleKey.split(this.viewSeparator);

			if (!categories) {
@@ -206,7 +208,7 @@ function(
					}
				}
				// Destruimos la zona
				zone.node && put(zone.node, "!");
				zone.node && put(zone.node, '!');
				zone.node = null;
			}
		},
@@ -218,14 +220,14 @@ function(
				if (!zone.node) {
					var node = this.rightContainer;

					if (zone.align == "left") {
					if (zone.align == 'left') {
						node = this.leftContainer;
					}

					zone.node = put(node, zone["class"], {});
					zone.node = put(node, zone['class'], {});
				}
				// Si tiene permisos de edición o no es la zona de edición
				if (this.perms > 0 || item !== "edit") {
				if (this.perms > 0 || item !== 'edit') {
					// Elementos tipo botón
					for (var key2 in zone.btns) {
						var btn = zone.btns[key2];
@@ -285,7 +287,7 @@ function(

		_downloadFile: function() {

			this._emitDownloadFile("pdf");
			this._emitDownloadFile('pdf');
		},

		_emitDownloadFile: function(/*String*/ format) {
+9 −6
Original line number Diff line number Diff line
define([
	"dojo/_base/declare"
	, "dojo/_base/lang"
	'app/redmicConfig'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
], function(
	declare
	redmicConfig
	, declare
	, lang
) {

	return declare(null, {
		//	summary:
		//		Base para todas las interfaces de módulos.
@@ -39,14 +42,14 @@ define([

		_onNotImplementedMethod: function(method, props) {

			if (envDebug === 'true') {
			if (redmicConfig.getEnvVariableValue('envDebug') === 'true') {
				this._showNotImplementedMethodWarning(method, props);
			}
		},

		_showNotImplementedMethodWarning: function(method, props) {

			console.warn("Not implemented method '%s' at module '%s' with this definition: %O", method,
			console.warn('Not implemented method "%s" at module "%s" with this definition: %O', method,
				this.getChannel(), props);
		}
	});
Loading