Skip to content

Commit a052336

Browse files
author
Nicole Garcia
committed
remove validation-token
1 parent 7cea61f commit a052336

File tree

5 files changed

+26
-34
lines changed

5 files changed

+26
-34
lines changed

src/app/guards/admin-guard/admin.guard.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ export class AdminGuard implements CanActivate {
1313
private userInfoService: UserInfoService,
1414
) { }
1515

16-
canActivate(): Observable<boolean> {
17-
return this.isAdminBasedInGroup().pipe(
18-
map((isAdmin: boolean) => {
19-
if (!isAdmin) { this.router.navigate(['login']); }
20-
return isAdmin;
21-
})
22-
);
16+
canActivate(){
17+
const isAdmin = this.isAdminBasedInGroup();
18+
if (!isAdmin) { this.router.navigate(['login']); }
19+
return isAdmin;
2320
}
2421

25-
isAdminBasedInGroup(): Observable<boolean> {
22+
isAdminBasedInGroup() {
2623
return this.userInfoService.isAdmin();
2724
}
2825
}

src/app/modules/login/services/login.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export class LoginService {
4747
const user = JSON.parse(token);
4848
return user && this.cookieService.check('idtoken') ? of(true) : of(false);
4949
} else {
50-
return this.isValidToken(token);
50+
return of(true);
51+
//return this.isValidToken(token);
5152
}
5253
}
5354

src/app/modules/shared/components/sidebar/sidebar.component.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { EnvironmentType } from 'src/environments/enum';
1414
templateUrl: './sidebar.component.html',
1515
styleUrls: ['./sidebar.component.scss'],
1616
})
17-
export class SidebarComponent implements OnInit, OnDestroy {
17+
export class SidebarComponent implements OnInit {
1818
itemsSidebar: ItemSidebar[] = [];
1919
navStart;
2020
sidebarItems$: Subscription;
@@ -34,42 +34,41 @@ export class SidebarComponent implements OnInit, OnDestroy {
3434

3535
ngOnInit(): void {
3636
const currentRouting = this.router.routerState.snapshot.url;
37-
this.sidebarItems$ = this.getSidebarItems().subscribe(() => this.highlightMenuOption(currentRouting));
37+
this.getSidebarItems();
38+
this.highlightMenuOption(currentRouting);
3839
this.navStart.subscribe((evt) => {
3940
this.highlightMenuOption(evt.url);
4041
});
4142
}
4243

43-
ngOnDestroy(): void {
44-
this.sidebarItems$.unsubscribe();
45-
}
4644

4745
toggleSideBar() {
4846
$('#wrapper').toggleClass('toggled');
4947
$('#show-sidebar').toggle();
5048
$('#hide-sidebar').toggle();
5149
}
5250

53-
getSidebarItems(): Observable<void> {
54-
return this.userInfoService.isAdmin().pipe(
55-
map((isAdmin) => {
56-
if (isAdmin) {
57-
this.itemsSidebar = [
51+
getSidebarItems(){
52+
if (this.userInfoService.isAdmin()){
53+
this.itemsSidebar = [
5854
{ route: '/time-clock', icon: 'far fa-clock', text: 'Time Clock', active: false },
5955
{ route: '/time-entries', icon: 'far fa-file-alt', text: 'Time Entries', active: false },
6056
{ route: '/reports', icon: 'fas fa-chart-bar', text: 'Reports', active: false },
6157
{ route: '/activities-management', icon: 'fas fa-list-ol', text: 'Activities', active: false },
6258
{ route: '/customers-management', icon: 'fas fa-users', text: 'Customers', active: false },
6359
{ route: '/users', icon: 'fas fa-user-friends', text: 'Users', active: false },
6460
];
65-
} else {
66-
this.itemsSidebar = [
67-
{ route: '/time-clock', icon: 'far fa-clock', text: 'Time Clock', active: false },
68-
{ route: '/time-entries', icon: 'far fa-file-alt', text: 'Time Entries', active: false },
69-
];
70-
}
71-
})
72-
);
61+
}else {
62+
this.itemsSidebar = [
63+
{ route: '/time-clock', icon: 'far fa-clock', text: 'Time Clock', active: false },
64+
{ route: '/time-entries', icon: 'far fa-file-alt', text: 'Time Entries', active: false },
65+
{ route: '/reports', icon: 'fas fa-chart-bar', text: 'Reports', active: false },
66+
{ route: '/activities-management', icon: 'fas fa-list-ol', text: 'Activities', active: false },
67+
{ route: '/customers-management', icon: 'fas fa-users', text: 'Customers', active: false },
68+
{ route: '/users', icon: 'fas fa-user-friends', text: 'Users', active: false },
69+
];
70+
}
71+
7372
}
7473

7574
highlightMenuOption(route) {

src/app/modules/shared/components/user/user.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ export class UserComponent implements OnInit {
2424
this.azureAdB2CService.setTenantId();
2525
}
2626
} else {
27-
this.loginService.isLogin().subscribe(isLogin => {
28-
if (isLogin) {
27+
if (this.loginService.isLogin()) {
2928
this.userName = this.loginService.getName();
3029
this.userEmail = this.loginService.getUserEmail();
3130
this.azureAdB2CService.setTenantId();
3231
}
33-
});
3432
}
3533
}
3634
}

src/app/modules/user/services/user-info.service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ export class UserInfoService {
2727
} else {
2828
const user = this.helper.decodeToken(token);
2929
const {groups = []} = user;
30-
if (groups.includes(groupName)) {
31-
return this.loginService.isValidToken(token);
32-
}
30+
return groups.includes(groupName);
3331
}
34-
return of(false);
3532
}
3633

3734
isAdmin(): Observable<boolean> {

0 commit comments

Comments
 (0)