fix: always use the same token

parent b90bf886
...@@ -2,7 +2,7 @@ import {Component, Input, OnInit} from '@angular/core'; ...@@ -2,7 +2,7 @@ import {Component, Input, OnInit} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser'; import {DomSanitizer} from '@angular/platform-browser';
import {NavList} from '../../ControlPage/control/control.component'; import {NavList} from '../../ControlPage/control/control.component';
import {User} from '../../globals'; import {User, guacamole_token} from '../../globals';
import {HttpService, LogService} from '../../app.service'; import {HttpService, LogService} from '../../app.service';
@Component({ @Component({
...@@ -23,17 +23,22 @@ export class ElementIframeComponent implements OnInit { ...@@ -23,17 +23,22 @@ export class ElementIframeComponent implements OnInit {
ngOnInit() { ngOnInit() {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens // /guacamole/api/tokens will redirect to http://guacamole/api/tokens
this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe( const base = window.btoa(this.host.hostname + '\0' + 'c' + '\0' + 'jumpserver');
data => { if (guacamole_token.length > 0) {
const base = window.btoa(this.host.hostname + '\0' + 'c' + '\0' + 'jumpserver'); this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + guacamole_token;
// /guacamole/client will redirect to http://guacamole/#/client } else {
this.target = document.location.origin + this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe(
'/guacamole/#/client/' + base + '?token=' + data['authToken']; data => {
}, // /guacamole/client will redirect to http://guacamole/#/client
error2 => { this.target = document.location.origin +
this._logger.error(error2); '/guacamole/#/client/' + base + '?token=' + data['authToken'];
} guacamole_token = data['authToken'];
); },
error2 => {
this._logger.error(error2);
}
);
}
} }
trust(url) { trust(url) {
......
...@@ -147,3 +147,4 @@ export let wsEvent: { ...@@ -147,3 +147,4 @@ export let wsEvent: {
export const i18n = new Map(); 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