Commit 5e207ee9 authored by zheng liu's avatar zheng liu

Merged in dev (pull request #78)

Dev
parents 44c6dd2d d6d3490e
......@@ -70,10 +70,11 @@ export class HttpService {
return this.http.get<Array<HostGroup>>('/api/perms/v1/user/nodes-assets/');
}
get_guacamole_token(user_id: string) {
get_guacamole_token(user_id: string, authToken: string) {
const body = new HttpParams()
.set('username', user_id)
.set('password', 'jumpserver');
.set('password', 'jumpserver')
.set('asset_token', authToken);
// {
// "authToken": "xxxxxxx",
// "username": "xxxxxx",
......@@ -127,6 +128,14 @@ export class HttpService {
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()
......
......@@ -31,7 +31,8 @@ export class ElementGuacamoleComponent implements OnInit {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
if (this.token) {
this.userid = this._localStorage.get('user');
this._http.get_guacamole_token(this.userid).subscribe(
if (this.userid) {
this._http.get_guacamole_token(this.userid, this.token).subscribe(
data => {
DataStore.guacamole_token = data['authToken'];
this._http.guacamole_token_add_asset(this.token, data['authToken']).subscribe(
......@@ -44,6 +45,15 @@ export class ElementGuacamoleComponent implements OnInit {
}
);
});
} else {
this._http.get_user_id_from_token(this.token)
.subscribe(
data => {
this._localStorage.set('user', data['user']);
}
);
}
} else {
const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver');
if (environment.production) {
......@@ -57,7 +67,7 @@ export class ElementGuacamoleComponent implements OnInit {
}
);
} else {
this._http.get_guacamole_token(User.id).subscribe(
this._http.get_guacamole_token(User.id, '').subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamole_token = data['authToken'];
......
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