浏览代码

add logout

master
Christian Ziermann 3 年前
父节点
当前提交
ce55ba29af
共有 3 个文件被更改,包括 17 次插入2 次删除
  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 查看文件

@@ -232,7 +232,7 @@ export class RulesService implements RulesServiceInterface {
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_,
withCredentials: this.configuration.withCredentials,

+ 4
- 0
src/app/footer/footer.component.html 查看文件

@@ -5,4 +5,8 @@
<span [routerLink]="['/admin/create']">
<mat-icon>add</mat-icon>
</span>

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

+ 12
- 1
src/app/footer/footer.component.ts 查看文件

@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../auth/service/auth.service';

@Component({
selector: 'app-footer',
@@ -7,9 +9,18 @@ import { Component, OnInit } from '@angular/core';
})
export class FooterComponent implements OnInit {

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

ngOnInit(): void {
}

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

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

}

正在加载...
取消
保存