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,18 +23,23 @@ export class ElementIframeComponent implements OnInit {
ngOnInit() {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
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 => {
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'];
guacamole_token = data['authToken'];
},
error2 => {
this._logger.error(error2);
}
);
}
}
trust(url) {
return this.sanitizer.bypassSecurityTrustResourceUrl(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