This file contains hidden or 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
export const loggedInGuard: CanActivateFn = () => { | |
const jwtService = inject(JwtService); | |
return !!jwtService.getToken(); | |
}; | |
describe('loggedInGuard', () => { | |
it('should return true', waitForAsync(async () => { | |
TestBed.configureTestingModule({ | |
providers: [ |
This file contains hidden or 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 { ApplicationConfig, importProvidersFrom } from '@angular/core'; | |
import { provideRouter } from '@angular/router'; | |
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; | |
import { provideFirebaseApp } from '@angular/fire/app'; | |
import { provideAuth } from '@angular/fire/auth'; | |
import { provideFirestore } from '@angular/fire/firestore'; | |
import { provideStorage } from '@angular/fire/storage'; | |
import { provideFunctions } from '@angular/fire/functions'; | |
import { initializeApp, getApp } from 'firebase/app'; | |
import { connectAuthEmulator, getAuth } from 'firebase/auth'; |
This file contains hidden or 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
const app = initializeApp(environment.firebase); | |
export const AUTH = new InjectionToken('Firebase auth', { | |
providedIn: 'root', | |
factory: () => { | |
const auth = getAuth(); | |
if (environment.useEmulators) { | |
connectAuthEmulator(auth, 'http://localhost:9099', { | |
disableWarnings: true, | |
}); |