Skip to content

Commit

Permalink
add guards
Browse files Browse the repository at this point in the history
  • Loading branch information
annamar26 committed Jan 25, 2022
1 parent 06d4fee commit 4c4d165
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions blackrock/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv:[
`./jest.config.js`
]
};
18 changes: 10 additions & 8 deletions blackrock/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import { QuizMainComponent } from './pages/quiz-main/quiz-main.component';
import { ProfileComponent } from './pages/profile/profile.component';
import { CoursesComponent } from './pages/courses/courses.component';
import { SpinnerComponent } from './pages/spinner/spinner.component';
import { AngularFireAuthGuard, redirectLoggedInTo, redirectUnauthorizedTo } from '@angular/fire/compat/auth-guard';


const redirectLoggedInToILogin = () => redirectLoggedInTo(['profile']);
const redirectUnauthorizedToLogin = () => redirectUnauthorizedTo(['']);
const routes: Routes = [
{ path:"", component:HomeComponent, pathMatch:"full"},
{path:"quiz", component:QuizComponent, pathMatch:"full"},
{ path:"edit", component:EditProfileComponent, pathMatch:"full"},
{path:"results", component:ResultsComponent, pathMatch:"full"},
{ path:"startquiz", component:QuizMainComponent, pathMatch:"full"},
{path:"profile", component:ProfileComponent, pathMatch:"full"},
{path:"courses", component:CoursesComponent, pathMatch:"full"},
{path:"loading", component:SpinnerComponent, pathMatch:"full"},
{path:"quiz", component:QuizComponent, pathMatch:"full", canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectLoggedInToILogin }},
{ path:"edit", component:EditProfileComponent, pathMatch:"full", canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin }},
{path:"results", component:ResultsComponent, pathMatch:"full", canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectLoggedInToILogin }},
{ path:"startquiz", component:QuizMainComponent, pathMatch:"full", canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectLoggedInToILogin }},
{path:"profile", component:ProfileComponent, pathMatch:"full", canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin }},
{path:"courses", component:CoursesComponent, pathMatch:"full", canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin }},
{path:"loading", component:SpinnerComponent, pathMatch:"full", canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectLoggedInToILogin }},
{ path: '**', redirectTo:"", pathMatch:'full'}

];
Expand Down

0 comments on commit 4c4d165

Please sign in to comment.