Commit 89b104e3 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Omite checks de Task, anula instancia para guest

En lugar de añadir comprobaciones para permitir o denegar el acceso a
publicarle al componente Task, se evita en primer lugar la creación de
su instancia cuando el usuario es invitado. Solamente se instanciaba en
estos casos para mandar a mostrar el aviso de registro necesario.

Se comprueba y lanza el aviso si es necesario antes de realizar la
acción restringida, por ahora sólo la generación de informes pdf.
parent a2857c6e
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -186,8 +186,7 @@ define([
				parentChannel: this.getChannel()
			});

			var userRole = Credentials.get('userRole');
			if (userRole !== 'ROLE_GUEST') {
			if (!Credentials.userIsGuest()) {
				new Notification({
					parentChannel: this.getChannel()
				});
@@ -195,17 +194,17 @@ define([
				new Socket({
					parentChannel: this.getChannel()
				});
			}

				var TaskDefinition = Task;

			if (userRole === 'ROLE_ADMINISTRATOR' || userRole === 'ROLE_OAG') {
				if (Credentials.userIsEditor()) {
					TaskDefinition = declare([TaskDefinition, _IngestData]);
				}

				new TaskDefinition({
					parentChannel: this.getChannel()
				});
			}

			this.topbar = new Topbar({
				parentChannel: this.getChannel(),
+0 −13
Original line number Diff line number Diff line
define([
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'src/util/Credentials'
	, 'src/util/GuestChecker'
], function(
	declare
	, lang
	, Credentials
	, GuestChecker
) {

	return declare(null, {
@@ -129,15 +125,6 @@ define([
		_chkSuccessfulStatus: function(status) {

			return status >= 200 && status < 400;
		},

		_chkUserIsNotGuest: function() {

			var userIsGuest = Credentials.get("userRole") === "ROLE_GUEST";

			userIsGuest && GuestChecker.protectFromGuests();

			return !userIsGuest;
		}
	});
});
+5 −19
Original line number Diff line number Diff line
@@ -71,28 +71,21 @@ define([

		_defineSubscriptions: function () {

			var commonOpts = this._getSubCommonOpts();

			this.subscriptionsConfig.push({
				channel : this.getChannel("REFRESH_STATUS"),
				callback: "_subRefreshStatus",
				options: commonOpts
				callback: "_subRefreshStatus"
			},{
				channel: this.getChannel("SOCKET_CONNECT"),
				callback: "_subSocketConnect",
				options: commonOpts
				callback: "_subSocketConnect"
			},{
				channel : this.getChannel("BUTTON_EVENT"),
				callback: "_subButtonEvent",
				options: commonOpts
				callback: "_subButtonEvent"
			},{
				channel : this.getChannel("REMOVE"),
				callback: "_subRemove",
				options: commonOpts
				callback: "_subRemove"
			},{
				channel : this.getChannel("ALL_TASK"),
				callback: "_subAllTask",
				options: commonOpts
				callback: "_subAllTask"
			});
		},

@@ -107,13 +100,6 @@ define([
			});
		},

		_getSubCommonOpts: function() {

			return {
				predicate: lang.hitch(this, this._chkUserIsNotGuest)
			};
		},

		_subRefreshStatus: function() {

			this._allTaskSocket({
+3 −8
Original line number Diff line number Diff line
@@ -54,20 +54,15 @@ define([

		_defineIngestDataSubscriptions: function () {

			var commonOpts = this._getSubCommonOpts();

			this.subscriptionsConfig.push({
				channel : this.getChannel("INGEST_DATA_RUN"),
				callback: "_subIngestDataRun",
				options: commonOpts
				callback: "_subIngestDataRun"
			},{
				channel : this.getChannel("INGEST_DATA_RESUME"),
				callback: "_subIngestDataResume",
				options: commonOpts
				callback: "_subIngestDataResume"
			},{
				channel : this.getChannel("INGEST_DATA_STOP"),
				callback: "_subIngestDataStop",
				options: commonOpts
				callback: "_subIngestDataStop"
			});
		},

+1 −4
Original line number Diff line number Diff line
@@ -59,12 +59,9 @@ define([

		_defineReportSubscriptions: function () {

			var commonOpts = this._getSubCommonOpts();

			this.subscriptionsConfig.push({
				channel : this.getChannel("GET_REPORT"),
				callback: "_subGetReport",
				options: commonOpts
				callback: "_subGetReport"
			});
		},

Loading