Skip to content

Commit

Permalink
Merge pull request #184 from SynBioDex/ownership-and-logout
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmyers authored Sep 9, 2021
2 parents c32843f + c2f45ed commit f367e63
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
17 changes: 15 additions & 2 deletions SBOLCanvasBackend/src/servlets/SynBioHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,21 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
user = sbhf.getUser();
body = user;

} else if (request.getPathInfo().equals("/listMyCollections")) {

} else if (request.getPathInfo().equals("/logout")) {

if(server == null || user == null) {
response.setStatus(HttpStatus.SC_BAD_REQUEST);
return;
}

SynBioHubFrontend sbhf = new SynBioHubFrontend(server);
sbhf.setUser(user);
sbhf.logout();
response.setStatus(HttpStatus.SC_OK);
return;

}else if (request.getPathInfo().equals("/listMyCollections")) {

if (server == null || user == null) {
response.setStatus(HttpStatus.SC_BAD_REQUEST);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ <h1 *ngIf="mode != classRef.SELECT_MODE" mat-dialog-title>Download</h1>
</div>

<div mat-dialog-actions>
<button mat-button [disabled]="loginDisabled()" (click)="onLoginClick()">Login</button>
<button mat-button *ngIf="!loginDisabled()" [disabled]="!registry" (click)="onLoginClick()">Login</button>
<button mat-button *ngIf="loginDisabled()" [disabled]="!registry" (click)="onLogoutClick()">Logout</button>
<button mat-button (click)="onCancelClick()">Cancel</button>
<button mat-button [disabled]="!enterCollectionEnabled()" (click)="onEnterCollectionClick()">Enter Collection</button>
<button *ngIf="mode != classRef.SELECT_MODE" mat-button [disabled]="!finishCheck()" (click)="onDownloadClick()">Download</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ export class DownloadGraphComponent implements OnInit {
});
}

async onLogoutClick() {
this.working = true;
await this.loginService.logout(this.registry);
this.working = false;
this.updateParts();
}

onCancelClick() {
this.dialogRef.close();
}
Expand Down
5 changes: 5 additions & 0 deletions SBOLCanvasFrontend/src/app/graph-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,11 @@ export class GraphHelpers extends GraphBase {
// edge case, module view, need to check parent circuit container
toCheck.add(cell.getParent().getValue());
}
} else if(cell.isCircuitContainer() && cell.getParent().isModuleView()){
// transition state to module views
toCheck.add(cell.getParent().getId());
} else if(cell.isModule()){
toCheck.add(cell.getParent().getId());
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions SBOLCanvasFrontend/src/app/login.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface LoginDialogData {
export class LoginService {

private loginURL = environment.backendURL + '/SynBioHub/login';
private logoutURL = environment.backendURL + '/SynBioHub/logout';

public users: {} = {};

Expand All @@ -39,4 +40,14 @@ export class LoginService {
return this.http.get(this.loginURL, { responseType: 'text', headers: headers, params: params });
}

async logout(server: string) {
let headers = new HttpHeaders();
headers = headers.set("Authorization", this.users[server]);
let params = new HttpParams();
params = params.append("server", server);
await this.http.get(this.logoutURL, { headers: headers, params: params }).toPromise();

delete this.users[server];
}

}

0 comments on commit f367e63

Please sign in to comment.