-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
598 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,37 @@ | ||
<div *ngIf="!isLoading"> | ||
<router-outlet></router-outlet> | ||
<div *authorizedContent="['Admin']">Authorized content section for Admin's (example)</div> | ||
<div *ngIf="!isLoading" class="centered-flex-container"> | ||
<h1>Frontegg App</h1> | ||
|
||
<div class='buttons-list'> | ||
<button *ngIf="!authenticated && fronteggAppService.fronteggApp.options.hostedLoginBox === true" data-test-id="open-hosted" (click)="loginWithRedirect()">Login</button> | ||
<a *ngIf="!authenticated && fronteggAppService.fronteggApp.options.hostedLoginBox === false" data-test-id="open-embedded" routerLink="/account/login"><button>Login</button></a> | ||
|
||
<button *ngIf="authenticated" data-test-id="open-admin-portal-btn" (click)="showApp()">Open Admin Portal</button> | ||
|
||
<span *ngIf="authenticated" (click)="logout()"><button>Logout</button></span> | ||
</div> | ||
|
||
<div *ngIf="authenticated"> | ||
<p>Authenticated as {{user?.name}}</p> | ||
</div> | ||
|
||
<div> | ||
{{ fronteggAppService.fronteggApp.options.hostedLoginBox ? 'Hosted' : 'Embedded' }} | ||
</div> | ||
|
||
<nav class="buttons-list"> | ||
Pages: | ||
<a routerLink="{{ROUTE_PATHS.HOME_PAGE}}"><button>Home</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.ENTITLEMENTS}}"><button>Entitlements</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.STEP_UP_NO_MAX_AGE}}"><button>Step up - no max age</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.STEP_UP_HIGH_MAX_AGE}}"><button>Step up - max age 5000</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.STEP_UP_SMALL_MAX_AGE}}"><button>Step up - max age 35</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.STEPPED_UP_FULL}}"><button>Stepped up (full)</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.AUTHORIZED_CONTENT}}"><button>Authorized content</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.TEST_PRIVATE_ROUTE}}"><button>Private route</button></a> | ||
<a routerLink="/{{ROUTE_PATHS.UNKNOWN_ROUTE}}"><button>Fallback route</button></a> | ||
</nav> | ||
|
||
<section class='router-content'> | ||
<router-outlet></router-outlet> | ||
</section> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.router-content { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
min-width: 600px; | ||
min-height: 400px; | ||
margin: 25px 0; | ||
padding: 10px; | ||
border: 2px dotted rgb(21, 125, 243); | ||
} | ||
|
||
.buttons-list { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 10px; | ||
} | ||
|
||
.buttons-list > * { | ||
margin-left: 4px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,63 @@ | ||
import { Component, OnDestroy, OnInit } from '@angular/core'; | ||
import { FronteggAppService } from '@frontegg/angular'; | ||
import { Router } from '@angular/router'; | ||
import { FronteggAppService, FronteggAuthService } from '@frontegg/angular'; | ||
import { Subscription } from 'rxjs'; | ||
import { ROUTE_PATHS } from './links'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'] | ||
}) | ||
export class AppComponent implements OnInit, OnDestroy { | ||
isLoading = true; | ||
loadingSubscription: Subscription; | ||
isAuthenticatedSubscription: Subscription; | ||
userSubscription?: Subscription; | ||
authenticated = false; | ||
user?: any; | ||
ROUTE_PATHS = ROUTE_PATHS; | ||
|
||
constructor(private fronteggAppService: FronteggAppService) { | ||
this.loadingSubscription = fronteggAppService.isLoading$.subscribe((isLoading) => this.isLoading = isLoading); | ||
constructor( | ||
public fronteggAppService: FronteggAppService, | ||
private fronteggAuthService: FronteggAuthService, | ||
private router: Router, | ||
) { | ||
this.loadingSubscription = fronteggAppService.isLoading$.subscribe((isLoading) => { | ||
this.isLoading = isLoading; | ||
}); | ||
|
||
this.isAuthenticatedSubscription = this.fronteggAppService.isAuthenticated$.subscribe((isAuthenticated: boolean) => { | ||
this.authenticated = isAuthenticated; | ||
}); | ||
} | ||
|
||
showApp(): void { | ||
this.fronteggAppService.showAdminPortal(); | ||
} | ||
|
||
logout(): void { | ||
if (this.fronteggAppService.fronteggApp.options.hostedLoginBox) { | ||
this.fronteggAuthService.logout(); | ||
return; | ||
} | ||
|
||
this.router.navigateByUrl(this.fronteggAppService.authRoutes.logoutUrl); | ||
} | ||
|
||
loginWithRedirect(): void { | ||
this.fronteggAuthService.loginWithRedirect(); | ||
} | ||
|
||
ngOnInit(): void { | ||
console.log('AppComponent', 'ngOnInit'); | ||
this.userSubscription = this.fronteggAuthService.user$.subscribe((user: any) => { | ||
this.user = user; | ||
}); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.loadingSubscription.unsubscribe(); | ||
this.isAuthenticatedSubscription.unsubscribe(); | ||
this.userSubscription?.unsubscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ects/example/src/app/components/authorized-content/authorized-content-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<section *ngIf="!authenticated"> | ||
Not Authenticated | ||
</section> | ||
|
||
<div><b>Admin</b> role section: (empty when not authorized)</div> | ||
<section class="authorized-section-container"> | ||
<div *authorizedContent="['Admin']"> | ||
Authorized content section for <b>Admin</b> role | ||
</div> | ||
</section> | ||
|
||
<div><b>Dora & Admin</b> role section: (empty when not authorized for both)</div> | ||
<section class="authorized-section-container"> | ||
<div *authorizedContent="['Dora', 'Admin']"> | ||
Authorized content section for <b>Dora & Admin</b> role | ||
</div> | ||
</section> | ||
|
||
<div><b>Dora</b> role section: (empty when not authorized)</div> | ||
<section class="authorized-section-container"> | ||
<div *authorizedContent="['Dora']"> | ||
Authorized content section for <b>Dora</b> role | ||
</div> | ||
</section> |
5 changes: 5 additions & 0 deletions
5
...ects/example/src/app/components/authorized-content/authorized-content-page.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.authorized-section-container { | ||
padding: 10px; | ||
margin: 8px 0 24px 0; | ||
border: 2px dotted rgb(21, 125, 243); | ||
} |
25 changes: 25 additions & 0 deletions
25
projects/example/src/app/components/authorized-content/authorized-content-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Component, OnDestroy, OnInit } from '@angular/core'; | ||
import { FronteggAppService } from '@frontegg/angular'; | ||
import { Subscription } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'authorized-content-page', | ||
templateUrl: 'authorized-content-page.component.html', | ||
styleUrls: ['authorized-content-page.component.scss'], | ||
}) | ||
export class AuthorizedContentPage implements OnInit, OnDestroy { | ||
authenticated = false; | ||
isAuthenticatedSubscription?: Subscription; | ||
|
||
constructor(private fronteggAppService: FronteggAppService) {} | ||
|
||
ngOnInit(): void { | ||
this.isAuthenticatedSubscription = this.fronteggAppService.isAuthenticated$.subscribe((isAuthenticated: boolean) => { | ||
this.authenticated = isAuthenticated; | ||
}); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.isAuthenticatedSubscription?.unsubscribe(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
projects/example/src/app/components/entitlements-page/entitlements-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<section *ngIf="!authenticated"> | ||
Not Authenticated | ||
</section> | ||
|
||
<section *ngIf="authenticated" class="outer-container"> | ||
<div class="boxes-container"> | ||
<span *ngFor="let ent of entitlementsResults | keyvalue"> | ||
<div *ngIf="ent.value.isEntitled" class="truthy"> | ||
{{ ent.value.name }} | ||
</div> | ||
|
||
<div *ngIf="!ent.value.isEntitled" class="falsy"> | ||
{{ ent.value.name }} | ||
<br/><br/> | ||
<i>{{ent.value.justification?.toString()}}</i> | ||
</div> | ||
</span> | ||
</div> | ||
|
||
<div class="centered-flex-container" [ngStyle]="{ 'flex-direction': 'row' }"> | ||
<button (click)="onLoadEntitlementsClicked()">Load entitlements</button> | ||
<button (click)="onLoadEntitlementsWithCallbackClicked()">Load entitlements with callback</button> | ||
</div> | ||
</section> |
49 changes: 49 additions & 0 deletions
49
projects/example/src/app/components/entitlements-page/entitlements-page.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.truthy { | ||
background-color: lightgreen; | ||
} | ||
|
||
.falsy { | ||
background-color: pink; | ||
} | ||
|
||
.truthy, .falsy { | ||
display: inline-block; | ||
height: 100px; | ||
width: 420px; | ||
word-wrap: break-word; | ||
margin: 10px; | ||
padding: 5px; | ||
border: 1px dotted black; | ||
|
||
animation: fadeInAnimation ease 3s; | ||
animation-iteration-count: 1; | ||
animation-fill-mode: forwards; | ||
|
||
@keyframes fadeInAnimation { | ||
0% { | ||
opacity: 0; | ||
} | ||
100% { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
|
||
.outer-container { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
} | ||
|
||
.boxes-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
max-width: 900px; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
} | ||
|
||
.centered-flex-container button { | ||
margin: 10px 10px 0 0; | ||
} |
Oops, something went wrong.