Commit b5651bef authored by ibuler's avatar ibuler

[Update] 设置guacamole注册申请的token

parent e1a91142
...@@ -63,11 +63,14 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -63,11 +63,14 @@ export class ElementGuacamoleComponent implements OnInit {
NavList.List[this.index].Rdp = this.el.nativeElement; NavList.List[this.index].Rdp = this.el.nativeElement;
return null; return null;
} }
if (!DataStore.guacamole_token) { const now = new Date();
const nowTime = now.getTime() / 1000;
if (!DataStore.guacamole_token || nowTime - DataStore.guacamole_token_time > 3600) {
this._http.get_guacamole_token(User.id, '').subscribe( this._http.get_guacamole_token(User.id, '').subscribe(
data => { data => {
// /guacamole/client will redirect to http://guacamole/#/client // /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamole_token = data['authToken']; DataStore.guacamole_token = data['authToken'];
DataStore.guacamole_token_time = nowTime;
this.registerHost(); this.registerHost();
}, },
error => { error => {
......
...@@ -91,6 +91,7 @@ export let DataStore: { ...@@ -91,6 +91,7 @@ export let DataStore: {
windowsize: Array<number>; windowsize: Array<number>;
autologin: boolean; autologin: boolean;
guacamole_token: string; guacamole_token: string;
guacamole_token_time: number;
} = { } = {
socket: io.connect(), socket: io.connect(),
Nav: [{}], Nav: [{}],
...@@ -102,7 +103,8 @@ export let DataStore: { ...@@ -102,7 +103,8 @@ export let DataStore: {
leftbarshow: true, leftbarshow: true,
windowsize: [], windowsize: [],
autologin: false, autologin: false,
guacamole_token: '' guacamole_token: '',
guacamole_token_time: 0
}; };
export let CSRF = ''; export let CSRF = '';
......
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