Browse Source

add logout

master
Christian Ziermann 3 years ago
parent
commit
ce55ba29af
3 changed files with 17 additions and 2 deletions
  1. +1
    -1
      api/api/rules.service.ts
  2. +4
    -0
      src/app/footer/footer.component.html
  3. +12
    -1
      src/app/footer/footer.component.ts

+ 1
- 1
api/api/rules.service.ts View File

responseType_ = 'text'; responseType_ = 'text';
} }


return this.httpClient.get<Array<Rule>>(`${this.configuration.basePath}/rules/admin`,
return this.httpClient.get<Array<Rule>>(`${this.configuration.basePath}/rules/admin/all`,
{ {
responseType: <any>responseType_, responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials, withCredentials: this.configuration.withCredentials,

+ 4
- 0
src/app/footer/footer.component.html View File

<span [routerLink]="['/admin/create']"> <span [routerLink]="['/admin/create']">
<mat-icon>add</mat-icon> <mat-icon>add</mat-icon>
</span> </span>

<span *ngIf="isLogedIn()" (click)="logout()">
<mat-icon>logout</mat-icon>
</span>
</mat-toolbar> </mat-toolbar>

+ 12
- 1
src/app/footer/footer.component.ts View File

import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../auth/service/auth.service';


@Component({ @Component({
selector: 'app-footer', selector: 'app-footer',
}) })
export class FooterComponent implements OnInit { export class FooterComponent implements OnInit {


constructor() { }
constructor(protected authService: AuthService, protected router: Router) { }


ngOnInit(): void { ngOnInit(): void {
} }


isLogedIn (): boolean {
return !!this.authService.user;
}

logout () {
this.authService.logout();
this.router.navigate(['login']);
}

} }

Loading…
Cancel
Save