import { inject, InjectionToken } from '@angular/core';
import { type CanActivateChildFn, type CanActivateFn } from '@angular/router';
import { authenticationPasswordGuard } from './adapters/authentication-password.guard';

export const AUTH_GUARD = new InjectionToken<CanActivateFn | CanActivateChildFn>('AuthGuard', {
  factory: () => authenticationPasswordGuard,
});

export const authenticationGuard: CanActivateFn = (route, state) => {
  const guard = inject(AUTH_GUARD);
  return guard(route, state);
};
