-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement admin guard, add refuges skeleton
- Loading branch information
1 parent
68d4144
commit 9ac5c69
Showing
9 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CanActivateFn, Router } from '@angular/router'; | ||
import { inject } from '@angular/core'; | ||
import { AuthService } from '../services/auth/auth.service'; | ||
|
||
export const adminGuard: CanActivateFn = async () => { | ||
const authService = inject(AuthService); | ||
const router = inject(Router); | ||
|
||
if (await authService.isAuthenticated()) { | ||
return true; | ||
} | ||
|
||
return router.parseUrl('/login'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/app/pages/refuges/refuges/refuges-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { RefugesPage } from './refuges.page'; | ||
import { adminGuard } from '../../../guards/admin.guard'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: RefugesPage, | ||
canActivate: [adminGuard], | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class RefugesPageRoutingModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { RefugesPageRoutingModule } from './refuges-routing.module'; | ||
|
||
import { RefugesPage } from './refuges.page'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, FormsModule, IonicModule, RefugesPageRoutingModule], | ||
declarations: [RefugesPage], | ||
}) | ||
export class RefugesPageModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ion-header [translucent]="true"> | ||
<ion-toolbar> | ||
<ion-title>refuges</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content [fullscreen]="true"> | ||
<ion-header collapse="condense"> | ||
<ion-toolbar> | ||
<ion-title size="large">refuges</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
</ion-content> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { RefugesPage } from './refuges.page'; | ||
|
||
describe('RefugesPage', () => { | ||
let component: RefugesPage; | ||
let fixture: ComponentFixture<RefugesPage>; | ||
|
||
beforeEach(async(() => { | ||
fixture = TestBed.createComponent(RefugesPage); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-refuges', | ||
templateUrl: './refuges.page.html', | ||
styleUrls: ['./refuges.page.scss'], | ||
}) | ||
export class RefugesPage implements OnInit { | ||
constructor() {} | ||
|
||
ngOnInit() {} | ||
} |