Skip to content

Commit

Permalink
set user and admin persmissions
Browse files Browse the repository at this point in the history
for user, CRU; for admin CRUD
  • Loading branch information
gmonso committed Dec 12, 2023
1 parent e7a05f1 commit 9f6db1f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const routes: Routes = [
{ path: 'about', component: AboutComponent},
{ path: '404', component: NotFoundComponent},
{ path: '', redirectTo: 'about', pathMatch: 'full'},
{ path: 'coordinates', loadChildren: () => import('./coordinate/coordinate-routing.module').then(m => m.CoordinateRoutingModule), canActivate: [CheckIsNotAdminGuard]},
{ path: 'coordinates', loadChildren: () => import('./coordinate/coordinate-routing.module').then(m => m.CoordinateRoutingModule), canActivate: [CheckLoggedInGuard]},
];

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export class CoordinateDetailComponent implements OnInit {
}

isRole(role: string): boolean {
// return this.authenticationService.isRole(role);
return true;
return this.authenticationService.isRole(role);
}

goBackToPrevPage(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h3>Coordinates List</h3>
</div>
<div class="col-md-6">
<div style="text-align: right;">
<button *ngIf="isRole('admin')" type="button" [routerLink]="['/coordinates/create']"
<button type="button" [routerLink]="['/coordinates/create']"
class="btn btn-outline-primary">Create
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ export class CoordinateListComponent implements OnInit {
}

isRole(role: string): boolean {
// return this.authenticationService.isRole(role);
return true;
return this.authenticationService.isRole(role);
}

getCurrentUserName(): string {
Expand Down
2 changes: 1 addition & 1 deletion src/app/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<a class="nav-link dropdown-toggle" id="coordinateDropdown" role="button"
aria-haspopup="true" aria-expanded="false" ngbDropdownToggle>Coordinate</a>
<div class="dropdown-menu" aria-labelledby="coordinateDropdown" ngbDropdownMenu>
<a class="dropdown-item" *ngIf="isRole('user')" [routerLinkActive]="'active'" [routerLinkActiveOptions]="{ exact: true }"
<a class="dropdown-item" [routerLinkActive]="'active'" [routerLinkActiveOptions]="{ exact: true }"
[routerLink]="['/coordinates/create']"><span class="fas fa-user-circle"></span> Create</a>
<a class="dropdown-item" [routerLinkActive]="'active'" [routerLinkActiveOptions]="{ exact: true }"
[routerLink]="['/coordinates']"><span class="fas fa-user-circle"></span> List</a>
Expand Down

0 comments on commit 9f6db1f

Please sign in to comment.