Skip to content

Commit

Permalink
perf: 修改Guacamole token的存储方式
Browse files Browse the repository at this point in the history
  • Loading branch information
orangemio authored and BaiJiangJie committed Feb 3, 2021
1 parent 10f7cf4 commit a38fc0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/app/elements/guacamole/guacamole.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export class ElementGuacamoleComponent implements OnInit {
this._http.getGuacamoleToken(this.token, this.token).subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamoleToken = data['authToken'];
localStorage.setItem('guacamoleToken', data['authToken']);
DataStore.guacamoleTokenTime = nowTime;
action = this._http.guacamoleTokenAddAsset(this.token).subscribe(
data2 => {
const base = data2['result'];
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamoleToken;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + localStorage.getItem('guacamoleToken');
setTimeout(() => this.setIdleTimeout(), 500);
},
error => {
Expand All @@ -70,7 +70,7 @@ export class ElementGuacamoleComponent implements OnInit {
action.subscribe(
data => {
const base = data.result;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamoleToken;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + localStorage.getItem('guacamoleToken');
setTimeout(() => this.setIdleTimeout(), 500);
},
error => {
Expand All @@ -90,7 +90,7 @@ export class ElementGuacamoleComponent implements OnInit {
this._http.getGuacamoleToken(User.id, '').subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamoleToken = data['authToken'];
localStorage.setItem('guacamoleToken', data['authToken']);
DataStore.guacamoleTokenTime = nowTime;
this.registerHost();
},
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class HttpService {
.set('user_id', userId)
.set('asset_id', assetId)
.set('system_user_id', systemUserId)
.set('token', DataStore.guacamoleToken);
.set('token', localStorage.getItem('guacamoleToken'));
let body = new HttpParams();
if (systemUserUsername && systemUserPassword) {
systemUserUsername = btoa(systemUserUsername);
Expand Down Expand Up @@ -216,7 +216,7 @@ export class HttpService {
.set('user_id', userId)
.set('remote_app_id', remoteAppId)
.set('system_user_id', sysUserId)
.set('token', DataStore.guacamoleToken);
.set('token', localStorage.getItem('guacamoleToken'));
let body = new HttpParams();
if (systemUserUsername && systemUserPassword) {
systemUserUsername = btoa(systemUserUsername);
Expand All @@ -243,7 +243,7 @@ export class HttpService {
guacamoleTokenAddAsset(assetToken: string) {
let params = new HttpParams()
.set('asset_token', assetToken)
.set('token', DataStore.guacamoleToken);
.set('token', localStorage.getItem('guacamoleToken'));
const resolution = this.settingSrv.setting.rdpResolution || 'Auto';
if (resolution !== 'Auto') {
const width = resolution.split('x')[0];
Expand Down

0 comments on commit a38fc0f

Please sign in to comment.