Unverified Commit f7e2511f authored by liuzheng712's avatar liuzheng712

fix: update

parents 30546d2e b62be119
...@@ -15,7 +15,6 @@ export class ConnectPageComponent implements OnInit { ...@@ -15,7 +15,6 @@ export class ConnectPageComponent implements OnInit {
userid: string; userid: string;
target: string; target: string;
base: string; base: string;
time: number;
constructor(private _appService: AppService, constructor(private _appService: AppService,
private _http: HttpService, private _http: HttpService,
...@@ -32,7 +31,6 @@ export class ConnectPageComponent implements OnInit { ...@@ -32,7 +31,6 @@ export class ConnectPageComponent implements OnInit {
this.userid = this._localStorage.get('user-' + this.token); this.userid = this._localStorage.get('user-' + this.token);
this.authToken = this._localStorage.get('authToken-' + this.token); this.authToken = this._localStorage.get('authToken-' + this.token);
this.base = this._localStorage.get('base-' + this.token); this.base = this._localStorage.get('base-' + this.token);
this.time = 0;
if (this.system === 'windows') { if (this.system === 'windows') {
...@@ -41,48 +39,52 @@ export class ConnectPageComponent implements OnInit { ...@@ -41,48 +39,52 @@ export class ConnectPageComponent implements OnInit {
.subscribe( .subscribe(
data => { data => {
this._localStorage.set('user-' + this.token, data['user']); this._localStorage.set('user-' + this.token, data['user']);
this.time = this.time + 1; this.getAuthToken();
} }
); );
} else { } else {
this.time = this.time + 1; this.getAuthToken();
}
}
} }
getAuthToken() {
if (!this.authToken) { if (!this.authToken) {
this._http.get_guacamole_token(this.userid, this.token).subscribe( this._http.get_guacamole_token(this.userid, this.token).subscribe(
data => { data => {
if (data['authToken']) { if (data['authToken']) {
this._localStorage.set('authToken-' + this.token, data['authToken']); this._localStorage.set('authToken-' + this.token, data['authToken']);
this.authToken = data['authToken']; this.authToken = data['authToken'];
this.time = this.time + 1; this.getBase();
} }
} }
); );
} else { } else {
this.time = this.time + 1; this.getBase();
}
} }
getBase() {
if (!this.base) { if (!this.base) {
this._http.guacamole_token_add_asset(this.token, this.authToken).subscribe( this._http.guacamole_token_add_asset(this.token, this.authToken).subscribe(
data => { data => {
if (data['result']) { if (data['result']) {
this._localStorage.set('base-' + this.token, data['result']); this._localStorage.set('base-' + this.token, data['result']);
this.base = data['result']; this.base = data['result'];
this.time = this.time + 1; this.setWinTarget();
} }
}); });
} else { } else {
this.time = this.time + 1; this.setWinTarget();
}
} }
setTimeout(() => {
if (this.time === 3) { setWinTarget() {
if (this.authToken && this.base) { if (this.base && this.authToken) {
this.target = document.location.origin + '/guacamole/#/client/' + this.base + this.target = document.location.origin + '/guacamole/#/client/' + this.base +
'?asset_token=jumpserver&token=' + this.authToken; '?asset_token=jumpserver&token=' + this.authToken;
} } else {
} window.location.reload();
},
50
);
} }
} }
......
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