Commit 02ef1565 authored by Chris Hines's avatar Chris Hines
Browse files

add an expiry field to the Identity (corresponding to the certificate expiry)...

add an expiry field to the Identity (corresponding to the certificate expiry) and display on the account info page
parent 77eef2da
Pipeline #12041 failed with stages
in 3 minutes and 5 seconds
<div fxLayout="column" fxLayoutAlign="start none" style="width: 100%" class="strudel-accountinfo-typography">
<div *ngIf="nowSeconds(identity$ | async) ; let time">
Login certificates expire in {{ time }}
</div>
<div *ngIf="identity$.value !== null && identity$.value !== undefined">
<!--<div *ngIf="identity$.value.systemalerts.value !== null">-->
<div *ngFor="let h of (identity$.value.systemalerts | async)">
......
......@@ -67,4 +67,27 @@ export class AccountinfoComponent implements OnInit {
}
}
nowSeconds(id: Identity) {
let seconds = (id.expiry - Date.now().valueOf())/1000;
console.log('seconds remaining',seconds);
let remaining = this.secondsToHms(seconds);
console.log('login seconds remaining',remaining);
return remaining;
}
secondsToHms(d: number) {
var sign = ""
if (d < 0) {
d = -d;
sign="-"
}
var h: number = Math.floor(d / 3600);
var m: number = Math.floor(d % 3600 / 60);
var s: number = Math.floor(d % 3600 % 60);
var hDisplay = h > 0 ? h + (h == 1 ? " hour " : " hours ") : "";
var mDisplay = m > 0 ? m + (m == 1 ? " minute " : " minutes ") : "";
return sign + hDisplay + mDisplay ;
}
}
......@@ -207,14 +207,13 @@ public getKeys(id?: Identity) {
catchError((e) => { this.querySshAgentError(e); return of([])}),
tap((resp) => { console.log('agent contents',resp) }),
tap((resp) => { console.log('agent contents',resp) }),
switchMap((resp) => of(this.addExpiryField(resp))),
tap((resp) => {
if (this.agentContents.value !== null && this.agentContents.value.length > resp.length) {
this.notifications.notify("Your login expired. Please login again");
console.log('login expired');
} else {
this.notifications.notify("");
};
console.log('updating agent contents');
this.agentContents.next(resp)
}),
catchError((e) => { console.error('updateAGentContents error',e) ; return of([])})
......@@ -223,6 +222,17 @@ public getKeys(id?: Identity) {
return agentpipe$
}
private addExpiryField(resp): any[] {
var res: any[]
res = []
for (let id of resp) {
var validstr: String;
validstr = id.Valid[0];
id.expiry = Date.parse(validstr.split(" ")[3])
res.push(id);
}
return res
}
private killAgent() {
this.notifications.notify("Logging out")
......
......@@ -204,7 +204,7 @@ export class ComputesitesService {
let principals = this.siteMatch(certs[i],cs);
for (let principal of principals) {
if (principal != null) {
let id = new Identity(principal,cs);
let id = new Identity(principal,cs,certs[i].expiry);
identities.push(id);
if (cs.appCatalogUri != null || cs.appCatalogCmd != null) {
appidentities.push(id);
......
......@@ -12,7 +12,8 @@ export class Identity {
accountalerts: BehaviorSubject<Health[]>;
joblist: BehaviorSubject<Job[]>;
quotas: any[];
constructor( username: string, site: Computesite) {
expiry: number;
constructor( username: string, site: Computesite, expiry: number) {
this.username = username;
this.site = site;
this.keyCerts = [];
......@@ -20,10 +21,11 @@ export class Identity {
this.accountalerts = new BehaviorSubject<Health[]>(null);
this.joblist = new BehaviorSubject<Job[]>([]);
this.quotas = [];
this.expiry = expiry;
}
copy_skip_catalog(): Identity {
let id = new Identity(null,null);
let id = new Identity(null,null,null);
id.username = this.username;
id.systemalerts = null;
id.accountalerts = null;
......
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