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">
|
<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 -->
|
<!-- Dropdown -->
|
||||||
<li class="nav-item dropdown" dropdown>
|
<li class="nav-item dropdown" dropdown>
|
||||||
<a role="button" data-toggle="dropdown" type="button" class="nav-link dropdown-toggle ">Profile</a>
|
<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">
|
<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>-->
|
<!-- <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>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import {AuthService} from "../services/auth/auth.service";
|
||||||
|
import {Router} from "@angular/router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-navbar',
|
selector: 'app-navbar',
|
||||||
|
|
@ -7,9 +9,16 @@ import { Component, OnInit } from '@angular/core';
|
||||||
})
|
})
|
||||||
export class NavbarComponent implements OnInit {
|
export class NavbarComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
constructor(public authservice: AuthService, private router: Router) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logout(){
|
||||||
|
//console.log('connecté ? '+this.authservice.getLogged());
|
||||||
|
console.log('test');
|
||||||
|
this.authservice.setLogged(false);
|
||||||
|
this.router.navigate(['/']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue