redirect after login works better
This commit is contained in:
@ -14,7 +14,7 @@ const routes: Routes = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [RouterModule.forRoot(routes)],
|
imports: [RouterModule.forRoot(routes, {onSameUrlNavigation:'reload'})],
|
||||||
exports: [RouterModule]
|
exports: [RouterModule]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -15,3 +15,7 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spacer {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
@ -6,8 +6,6 @@
|
|||||||
<mat-toolbar>Menu</mat-toolbar>
|
<mat-toolbar>Menu</mat-toolbar>
|
||||||
<mat-nav-list>
|
<mat-nav-list>
|
||||||
<a mat-list-item href="/test">Mein Test</a>
|
<a mat-list-item href="/test">Mein Test</a>
|
||||||
<a mat-list-item href="/login">Login</a>
|
|
||||||
<a mat-list-item href="/logout">Logout</a>
|
|
||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
</mat-sidenav>
|
</mat-sidenav>
|
||||||
<mat-sidenav-content>
|
<mat-sidenav-content>
|
||||||
@ -21,6 +19,9 @@
|
|||||||
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
|
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<span>Nober Grundbesitz GbR Hausverwaltung</span>
|
<span>Nober Grundbesitz GbR Hausverwaltung</span>
|
||||||
|
<span class="spacer"></span>
|
||||||
|
<a *ngIf="!authenticated" mat-button routerLink="/login">Login</a>
|
||||||
|
<a *ngIf="authenticated" mat-button routerLink="/logout">Logout</a>
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
<!-- Add Content Here -->
|
<!-- Add Content Here -->
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map, shareReplay } from 'rxjs/operators';
|
import { map, shareReplay } from 'rxjs/operators';
|
||||||
import { TokenService } from '../token.service';
|
import { TokenService } from '../token.service';
|
||||||
|
import { NavigationEnd, Router } from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-navigation',
|
selector: 'app-navigation',
|
||||||
@ -19,7 +20,16 @@ export class NavigationComponent {
|
|||||||
shareReplay()
|
shareReplay()
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(private breakpointObserver: BreakpointObserver, private tokenService: TokenService) {}
|
constructor(
|
||||||
|
private breakpointObserver: BreakpointObserver,
|
||||||
|
private tokenService: TokenService,
|
||||||
|
private router: Router) {
|
||||||
|
this.router.events.subscribe((e: any) => {
|
||||||
|
if (e instanceof NavigationEnd) {
|
||||||
|
this.authenticated = this.tokenService.checkAuthenticated()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.authenticated = this.tokenService.checkAuthenticated()
|
this.authenticated = this.tokenService.checkAuthenticated()
|
||||||
|
Reference in New Issue
Block a user