redirect after login works better
This commit is contained in:
@ -14,7 +14,7 @@ const routes: Routes = [
|
||||
]
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
imports: [RouterModule.forRoot(routes, {onSameUrlNavigation:'reload'})],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
|
||||
|
@ -15,3 +15,7 @@
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
@ -6,8 +6,6 @@
|
||||
<mat-toolbar>Menu</mat-toolbar>
|
||||
<mat-nav-list>
|
||||
<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-sidenav>
|
||||
<mat-sidenav-content>
|
||||
@ -21,6 +19,9 @@
|
||||
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
|
||||
</button>
|
||||
<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>
|
||||
<!-- Add Content Here -->
|
||||
|
||||
|
@ -3,6 +3,7 @@ import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, shareReplay } from 'rxjs/operators';
|
||||
import { TokenService } from '../token.service';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-navigation',
|
||||
@ -19,7 +20,16 @@ export class NavigationComponent {
|
||||
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() {
|
||||
this.authenticated = this.tokenService.checkAuthenticated()
|
||||
|
Reference in New Issue
Block a user