Skip to content

Commit 539c6ed

Browse files
author
Robinson Aizprua
committed
basic auth
1 parent 7ae69fc commit 539c6ed

File tree

10 files changed

+250
-44
lines changed

10 files changed

+250
-44
lines changed

ROAM/package-lock.json

Lines changed: 111 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ROAM/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@angular/platform-browser": "~7.2.0",
2222
"@angular/platform-browser-dynamic": "~7.2.0",
2323
"@angular/router": "~7.2.0",
24+
"auth0-js": "^9.10.2",
2425
"core-js": "^2.5.4",
2526
"rxjs": "~6.3.3",
2627
"tslib": "^1.9.0",

ROAM/src/app/app.component.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
</mat-slide-toggle>
1515
</div>
1616
<div >
17-
<button type="button" mat-button (click)="drawer.toggle()">
18-
User
17+
<button *ngIf="auth.isAuthenticated()" type="button" mat-button (click)="auth.login()">
18+
Logout
19+
</button>
20+
<button *ngIf="!auth.isAuthenticated()" type="button" mat-button (click)="auth.login()">
21+
Login
1922
</button>
2023
</div>
2124
</div>

ROAM/src/app/app.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit, HostBinding, ElementRef, HostListener } from '@angular/core';
2+
import { AuthService } from './services/auth.service';
23
export interface Menu {
34
name: string;
45
route: string;
@@ -26,10 +27,15 @@ export class AppComponent implements OnInit {
2627
defaultTheme:string = "my-theme";
2728
isMobile = /Android|iPhone/i.test(window.navigator.userAgent);
2829

29-
constructor() { }
30+
constructor(public auth: AuthService) {
31+
auth.handleAuthentication();
32+
}
3033

3134
ngOnInit(): void {
3235
this.changeMenuItemWidthMobileview();
36+
if (this.auth.isAuthenticated()) {
37+
this.auth.renewTokens();
38+
}
3339
}
3440

3541
onThemSwitch(event):void {

0 commit comments

Comments
 (0)