fix: always use the same token

parent b90bf886
......@@ -2,7 +2,7 @@ import {Component, Input, OnInit} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
import {NavList} from '../../ControlPage/control/control.component';
import {User} from '../../globals';
import {User, guacamole_token} from '../../globals';
import {HttpService, LogService} from '../../app.service';
@Component({
......@@ -23,17 +23,22 @@ export class ElementIframeComponent implements OnInit {
ngOnInit() {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe(
data => {
const base = window.btoa(this.host.hostname + '\0' + 'c' + '\0' + 'jumpserver');
// /guacamole/client will redirect to http://guacamole/#/client
this.target = document.location.origin +
'/guacamole/#/client/' + base + '?token=' + data['authToken'];
},
error2 => {
this._logger.error(error2);
}
);
const base = window.btoa(this.host.hostname + '\0' + 'c' + '\0' + 'jumpserver');
if (guacamole_token.length > 0) {
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + guacamole_token;
} else {
this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
this.target = document.location.origin +
'/guacamole/#/client/' + base + '?token=' + data['authToken'];
guacamole_token = data['authToken'];
},
error2 => {
this._logger.error(error2);
}
);
}
}
trust(url) {
......
......@@ -147,3 +147,4 @@ export let wsEvent: {
export const i18n = new Map();
export let guacamole_token = '';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment