How to use the @angular/fire/auth-guard.canActivate function in @angular/fire

To help you get started, we’ve selected a few @angular/fire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jamesdaniels / onSnapshot / src / app / app.module.ts View on Github external
import { AngularFireMessagingModule } from '@angular/fire/messaging';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    NavComponent
  ],
  imports: [
    CommonModule,
    BrowserModule.withServerTransition({appId: 'my-app'}),
    ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}),
    RouterModule.forRoot([
      { path: '', component: HomeComponent, pathMatch: 'full'},
      { path: 'articles/:id', loadChildren: () => import('./article/article.module').then(m => m.ArticleModule)},
      { path: 'authors/:id', loadChildren: () => import('./author/author.module').then(m => m.AuthorModule), ...canActivate(loggedIn)}
    ], { preloadingStrategy: PreloadAllModules, initialNavigation: 'enabled' }),
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireAuthModule,
    AngularFireDatabaseModule,
    AngularFirestoreModule.enablePersistence(),
    AngularFireAuthGuardModule,
    AngularFirePerformanceModule,
    AngularFireMessagingModule
    //PrebootModule.withConfig({ appRoot: 'app-root' })
  ],
  bootstrap: [ ],
  providers: [
//    { provide: EnableStateTransferToken, useValue: true }
  ]
})
export class AppModule { }
github angular / angularfire / test / ng-build / ng8 / src / app / app.component.ts View on Github external
constructor(
    private readonly app: FirebaseApp,
    private readonly db: AngularFireDatabase,
    private readonly auth: AngularFireAuth,
    private readonly afStore: AngularFirestore,
    private readonly storage: AngularFireStorage,
    private readonly messaging: AngularFireMessaging,
    private readonly functions: AngularFireFunctions,
    private readonly performance: AngularFirePerformance,
    private readonly appRef: ApplicationRef
  ) {
    const authArgs = canActivate(loggedIn);
    console.log(app, db, auth, afStore, storage, messaging, functions, performance, authArgs);
    appRef.isStable.subscribe(it => console.log("isStable", it));
  }
}
github javebratt / ionic-angular-firebase-authentication-starter / src / app / app-routing.module.ts View on Github external
...canActivate(redirectToLogin)
  },
  { path: 'login', loadChildren: './pages/login/login.module#LoginPageModule' },
  {
    path: 'signup',
    loadChildren: './pages/signup/signup.module#SignupPageModule'
  },
  {
    path: 'reset-password',
    loadChildren:
    './pages/reset-password/reset-password.module#ResetPasswordPageModule'
  },
  {
    path: 'profile',
    loadChildren: './pages/profile/profile.module#ProfilePageModule',
    ...canActivate(redirectToLogin)
  }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
  ],
  exports: [RouterModule]
})
export class AppRoutingModule {}