changed base project files

This commit is contained in:
Marta Borgia Leiva 2026-02-09 20:17:34 +01:00
parent 2cf0856db5
commit 0d82ea47c3
Signed by: a-mayb3
GPG key ID: 293AAC4FED165CE3
6 changed files with 117 additions and 343 deletions

View file

@ -1,11 +1,38 @@
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
import { ApplicationConfig, provideBrowserGlobalErrorListeners, APP_INITIALIZER } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { catchError, of } from 'rxjs';
import { routes } from './app.routes';
import { httpInterceptor } from './interceptors/http.interceptor';
import { AuthService } from './services/auth.service';
/**
* Initialize auth state on app startup by checking for existing session
*/
function initializeAuth(authService: AuthService) {
return () => authService.checkSession().pipe(
catchError((error) => {
// Session check failed - user is not logged in or session expired
console.log('No active session or session expired');
authService.clearAuthState();
return of(null);
})
);
}
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideRouter(routes)
provideRouter(routes),
provideHttpClient(
withInterceptors([httpInterceptor])
),
{
provide: APP_INITIALIZER,
useFactory: initializeAuth,
deps: [AuthService],
multi: true
}
]
};