Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
GFBio fix for SSO until we implement it fully.
Browse files Browse the repository at this point in the history
 * login menu shows only hint regarding portal login if in iframe (in the portal)
  • Loading branch information
ChristianBeilschmidt committed Nov 6, 2019
1 parent 8c1b93b commit 15bb867
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/app/users/login/login.component.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
<ng-template [ngIf]="isLoggedOut$ | async">
<wave-sidenav-header>Login</wave-sidenav-header>
<form [formGroup]="loginForm" (ngSubmit)="$event.preventDefault();login()">
<mat-button-toggle-group *waveIfGfbio formControlName="loginAuthority" fxLayout="row">
<mat-button-toggle-group *ngIf="false" formControlName="loginAuthority" fxLayout="row">
<mat-button-toggle value="system" fxFlex>System</mat-button-toggle>
<mat-button-toggle value="gfbio" fxFlex><img src="assets/logo_gfbio.png" alt="GFBio"></mat-button-toggle>
</mat-button-toggle-group>
<mat-card class="info" *ngIf="loginForm.controls.loginAuthority.value === 'gfbio'">
In case you are using the new GFBio Single Sign On, please login via <a href="https://www.gfbio.org">www.gfbio.org</a>.
<mat-card class="info" *ngIf="loginForm.controls.loginAuthority.value === 'gfbio' && !appInIframe">
In case you are using the new GFBio single sign on, please login via <a href="https://www.gfbio.org">www.gfbio.org</a>.
You can still login with your legacy GFBio account.
</mat-card>
<mat-form-field>
<mat-card class="info" *ngIf="loginForm.controls.loginAuthority.value === 'gfbio' && appInIframe">
VAT is using the new GFBio single sign on.
For now, please login via the portal.
</mat-card>
<mat-form-field *ngIf="!(loginForm.controls.loginAuthority.value === 'gfbio' && appInIframe)">
<input matInput type="text" placeholder="Username" formControlName="username">
</mat-form-field>
<mat-form-field>
<mat-form-field *ngIf="!(loginForm.controls.loginAuthority.value === 'gfbio' && appInIframe)">
<input matInput type="password" placeholder="Password" formControlName="password">
</mat-form-field>
<p class="error" *ngIf="invalidCredentials$ | async">Invalid Credentials</p>
<mat-checkbox formControlName="staySignedIn">Stay signed in</mat-checkbox>
<button mat-raised-button type="submit" [disabled]="(loginForm.statusChanges | async) !== 'VALID'" color="primary">
<mat-checkbox formControlName="staySignedIn" *ngIf="!(loginForm.controls.loginAuthority.value === 'gfbio' && appInIframe)">Stay signed in</mat-checkbox>
<button mat-raised-button type="submit"
*ngIf="!(loginForm.controls.loginAuthority.value === 'gfbio' && appInIframe)"
[disabled]="(loginForm.statusChanges | async) !== 'VALID'" color="primary">
Login
</button>
</form>
Expand Down
10 changes: 10 additions & 0 deletions src/app/users/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class LoginComponent implements OnInit, AfterViewInit {
user: Observable<User>;
invalidCredentials$ = new BehaviorSubject<boolean>(false);

appInIframe = this.isAppInIframe();

constructor(private formBuilder: FormBuilder,
private config: Config,
private userService: UserService,
Expand Down Expand Up @@ -128,4 +130,12 @@ export class LoginComponent implements OnInit, AfterViewInit {
error => this.notificationService.error(`The backend is currently unavailable (${error})`));
}

private isAppInIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}

}

0 comments on commit 15bb867

Please sign in to comment.