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

Controla casos de ausencia de token de usuario

parent 84896536
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -193,7 +193,14 @@ define([

			if (!this._tokenPayloadDfd) {
				this._tokenPayloadDfd = new Deferred();
				this._requestTokenPayload();

				const token = Credentials.get('oidAccessToken');

				if (token?.length) {
					this._requestTokenPayload(token);
				} else {
					this._tokenPayloadDfd.resolve();
				}
			}

			return this._tokenPayloadDfd;
@@ -256,14 +263,12 @@ define([
			});
		},

		_requestTokenPayload: function() {
		_requestTokenPayload: function(token) {
			// summary:
			//   Permite obtener el contenido del JWT del usuario pidiéndoselo al servidor para su verificación
			// tags:
			//   private

			const token = Credentials.get('oidAccessToken');

			this._emitEvt('REQUEST', {
				method: 'POST',
				target: this._tokenPayloadTarget,
+20 −4
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ define([
			this._prepareDashboardConfig();

			let tokenDfd = this._getGuestToken();
			tokenDfd.then(lang.hitch(this, this._prepareDashboardInstance));
			tokenDfd.then(() => this._prepareDashboardInstance(), () => this._missingUserToken());
		},

		_prepareDashboardConfig: function() {
@@ -107,16 +107,32 @@ define([

			this._guestToken = new Deferred();

			const userToken = Credentials.get('oidAccessToken');

			if (userToken?.length) {
				this._requestGuestToken(userToken);
			} else {
				this._guestToken.reject();
			}

			return this._guestToken;
		},

		_missingUserToken: function() {

			// TODO
		},

		_requestGuestToken: function(token) {

			this._emitEvt('GET', {
				target: this.target,
				requesterId: this.getOwnChannel(),
				id: this.dashboardConfig.id,
				query: {
					token: Credentials.get('oidAccessToken')
					token
				}
			});

			return this._guestToken;
		},

		_prepareDashboardInstance: function() {