diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 5f82d11aadeb911da708b5f9efa4dc419ce5a933..32636a1d17f19f229ea1e991ab297c556febc524 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,7 +8,6 @@ import { StructureListPrintComponent } from './form/orientation-form/component/s import { OrientationFormComponent } from './form/orientation-form/orientation-form.component'; import { AdminGuard } from './guards/admin.guard'; import { AuthGuard } from './guards/auth.guard'; -import { LoginGuard } from './guards/login.guard'; import { LegalNoticeComponent } from './legal-notice/legal-notice.component'; import { LoginComponent } from './login/login.component'; import { NewsletterSubscriptionComponent } from './newsletter-subscription/newsletter-subscription.component'; @@ -167,7 +166,7 @@ const routes: Routes = [ children: [ { path: '', - canActivate: [LoginGuard], + canActivate: [AuthGuard], component: StructureExcludeComponent, }, footerOutletRoute, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0e71f948fc1f0128db718a7f52479464f27d8fcc..0a57db88a01552663c1510717aadb717489b7533 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,7 +22,6 @@ import { LegalNoticeComponent } from './legal-notice/legal-notice.component'; import { PageComponent } from './page/page.component'; import { ContactComponent } from './contact/contact.component'; import { AuthGuard } from './guards/auth.guard'; -import { LoginGuard } from './guards/login.guard'; import { CustomHttpInterceptor } from './config/http-interceptor'; import { ResetEmailComponent } from './reset-email/reset-email.component'; import { ResetPasswordComponent } from './reset-password/reset-password.component'; @@ -102,7 +101,6 @@ import { FilterModalComponent } from './annuaire/filter-modal/filter-modal.compo AuthGuard, AdminGuard, RoleGuard, - LoginGuard, DeactivateGuard, TempUserResolver, StructureResolver, diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index d77c855f4e47f0521278d9784d572cc34b47d580..456ada45acc756f56f2fbbcf26bfc400d87ac5fa 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -12,7 +12,7 @@ export class AuthGuard implements CanActivate { if (this.authService.isLoggedIn()) { return true; } - this.router.navigate(['/home'], { queryParams: { returnUrl: state.url } }); + this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } }); return false; } } diff --git a/src/app/guards/login.guard.ts b/src/app/guards/login.guard.ts deleted file mode 100644 index b2d8e5b7f7ef49917feab39e237f9ef49968c5cb..0000000000000000000000000000000000000000 --- a/src/app/guards/login.guard.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router'; -import { Injectable } from '@angular/core'; -import { AuthService } from '../services/auth.service'; -/** - * Guard to assert that we are logged in. Otherwise redirect to home - */ -@Injectable() -export class LoginGuard implements CanActivate { - constructor(private authService: AuthService, private router: Router) {} - - canActivate(_next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - if (this.authService.isLoggedIn()) { - return true; - } - this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } }); - return false; - } -}