Created
May 11, 2018 09:15
-
-
Save DrDanL/33397da6b3cc2055fb5a8eb72c8a2015 to your computer and use it in GitHub Desktop.
Example of canActiveRoutes.js in protecting routes using Firebase. See https://leightley.com/angular-2-and-firebase-authentication-route-guard/
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
import { ModuleWithProviders } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { AppComponent } from './app.component'; | |
import { AuthGuard } from "./services/authGuard.service"; | |
import { LoginComponent } from "./views/login/login.component"; | |
import { SignupComponent } from './views/signup/signup.component'; | |
import { DashboardComponent } from "./views/dashboard/dashboard.component"; | |
export const router: Routes = [ | |
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' }, | |
{ path: 'login', component: LoginComponent }, | |
{ path: 'signup', component: SignupComponent }, | |
{ path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard] }, | |
] | |
export const AppRoutes: ModuleWithProviders = RouterModule.forRoot(router); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment