Skip to content

Commit

Permalink
Update imports and add authentication check in AppComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlabicani committed Mar 14, 2024
1 parent ffe85f9 commit 70343c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { Component, OnInit, inject } from '@angular/core';
import { Router, RouterOutlet } from '@angular/router';
import { Auth } from '@angular/fire/auth';
import { environment } from '../environments/environment';

@Component({
Expand All @@ -9,9 +10,18 @@ import { environment } from '../environments/environment';
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
export class AppComponent {
export class AppComponent implements OnInit {
auth = inject(Auth);
router = inject(Router);

title = 'seawatch';
constructor() {

ngOnInit(): void {
this.auth.onAuthStateChanged((user) => {
if (!user) {
this.router.navigate(['/login']);
}
});
console.log(environment.production);
}
}
2 changes: 1 addition & 1 deletion src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getFirestore,
provideFirestore,
} from '@angular/fire/firestore';
import { environment } from '../environments/environment';
import { environment } from '../environments/environment.development';

export const appConfig: ApplicationConfig = {
providers: [
Expand Down
File renamed without changes.

0 comments on commit 70343c2

Please sign in to comment.