feat: update

parent 4363db72
...@@ -128,6 +128,14 @@ export class HttpService { ...@@ -128,6 +128,14 @@ export class HttpService {
return this.http.get('/api/terminal/v1/sessions/' + token + '/replay'); return this.http.get('/api/terminal/v1/sessions/' + token + '/replay');
} }
get_user_id_from_token(token: string) {
const params = new HttpParams()
.set('user-only', '1')
.set('token', token);
return this.http.get('/api/users/v1/connection-token/', {params: params});
}
} }
@Injectable() @Injectable()
......
...@@ -31,19 +31,29 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -31,19 +31,29 @@ export class ElementGuacamoleComponent implements OnInit {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens // /guacamole/api/tokens will redirect to http://guacamole/api/tokens
if (this.token) { if (this.token) {
this.userid = this._localStorage.get('user'); this.userid = this._localStorage.get('user');
this._http.get_guacamole_token(this.userid, this.token).subscribe( if (this.userid) {
data => { this._http.get_guacamole_token(this.userid, this.token).subscribe(
DataStore.guacamole_token = data['authToken']; data => {
this._http.guacamole_token_add_asset(this.token, data['authToken']).subscribe( DataStore.guacamole_token = data['authToken'];
data2 => { this._http.guacamole_token_add_asset(this.token, data['authToken']).subscribe(
this._logger.debug(data); data2 => {
this.target = document.location.origin + '/guacamole/#/client/' + data2['result'] + '?token=' + data['authToken']; this._logger.debug(data);
}, this.target = document.location.origin + '/guacamole/#/client/' + data2['result'] + '?token=' + data['authToken'];
error2 => { },
this._logger.error(error2); error2 => {
this._logger.error(error2);
}
);
});
} else {
this._http.get_user_id_from_token(this.token)
.subscribe(
data => {
this._localStorage.set('user', data['user']);
} }
); );
});
}
} else { } else {
const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver'); const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver');
if (environment.production) { if (environment.production) {
......
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