From b7aca11a386dce86546b79bb396170662392a2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Fri, 5 May 2023 11:37:52 +0200 Subject: [PATCH] fix --- src/app/component/list/list.component.html | 2 ++ src/app/component/login/login.component.ts | 4 ++-- src/app/component/management/management.component.ts | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/component/list/list.component.html b/src/app/component/list/list.component.html index 52ab192..9071480 100644 --- a/src/app/component/list/list.component.html +++ b/src/app/component/list/list.component.html @@ -38,4 +38,6 @@ +
70%
+ diff --git a/src/app/component/login/login.component.ts b/src/app/component/login/login.component.ts index 825a47a..5fa9b28 100644 --- a/src/app/component/login/login.component.ts +++ b/src/app/component/login/login.component.ts @@ -46,7 +46,7 @@ export class LoginComponent implements OnInit { this.newUser.password = createUser.password; this.userService.createUser(this.newUser).subscribe(user => { this.cookieService.setUsername(createUser.username); - this.router.navigate(['/management']); + this.router.navigate(['/home']); }); }); } @@ -55,7 +55,7 @@ export class LoginComponent implements OnInit { this.userService.getUser(username).subscribe(user => { if (user.password == password) { this.cookieService.setUsername(username); - this.router.navigate(['/management']); + this.router.navigate(['/home']); } else { this.errorLogin = true; } diff --git a/src/app/component/management/management.component.ts b/src/app/component/management/management.component.ts index 5956763..efedd8c 100644 --- a/src/app/component/management/management.component.ts +++ b/src/app/component/management/management.component.ts @@ -2,7 +2,7 @@ import {Component, OnInit} from '@angular/core'; import {UserEntity} from "../../interface/UserEntity"; import {LocationEntity} from "../../interface/LocationEntity"; import {WaypointsEntity} from "../../interface/WaypointsEntity"; -import {ActivatedRoute} from "@angular/router"; +import {Router} from "@angular/router"; import {LocationService} from "../../service/http/location.service"; import {UserService} from "../../service/http/user.service"; import {WaypointService} from "../../service/http/waypoint.service"; @@ -35,7 +35,7 @@ export class ManagementComponent implements OnInit { translations: managementTranslations = {} as managementTranslations constructor( - private route: ActivatedRoute, + private route: Router, private locationService: LocationService, private waypointService: WaypointService, private userService: UserService, @@ -48,6 +48,11 @@ export class ManagementComponent implements OnInit { ngOnInit(): void { this.translations = this.readTranslationJsonService.getManagementTranslations(); this.username = this.cookieService.getUsername(); + this.userService.getUser(this.username).subscribe(user => { + if (user.admin == false) { + this.route.navigate(['/home']); + } + }); this.locationService.getLocations().subscribe(locations => { this.locations = locations; });