Add logout button (not working, no AuthGuard)
This commit is contained in:
parent
fe7b142a5c
commit
95c08668f7
2 changed files with 14 additions and 5 deletions
|
|
@ -1,14 +1,14 @@
|
|||
<nav class="navbar navbar-expand-lg navbar-light bg-primary">
|
||||
<a class="navbar-brand" href="#">Chat Polytech</a>
|
||||
<a class="navbar-brand" href="/chat">Chat Polytech</a>
|
||||
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<ul class="navbar-nav ml-auto" *ngIf="true;">
|
||||
<!-- Dropdown -->
|
||||
<li class="nav-item dropdown" dropdown>
|
||||
<a role="button" data-toggle="dropdown" type="button" class="nav-link dropdown-toggle ">Profile</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown dropdown-primary" role="menu">
|
||||
<a class="dropdown-item waves-light" href="#">Change password</a>
|
||||
<a class="dropdown-item waves-light" href="changePassword">Change password</a>
|
||||
<!-- <div class="divider dropdown-divider"></div>-->
|
||||
<a class="dropdown-item waves-light" href="#">Log out</a>
|
||||
<a class="dropdown-item waves-light" href="#" (click)="logout()">Log out</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import {AuthService} from "../services/auth/auth.service";
|
||||
import {Router} from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: 'app-navbar',
|
||||
|
|
@ -7,9 +9,16 @@ import { Component, OnInit } from '@angular/core';
|
|||
})
|
||||
export class NavbarComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
constructor(public authservice: AuthService, private router: Router) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
logout(){
|
||||
//console.log('connecté ? '+this.authservice.getLogged());
|
||||
console.log('test');
|
||||
this.authservice.setLogged(false);
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue