fixed routing logic
This commit is contained in:
@@ -8,7 +8,6 @@ import { institutionResolver } from './resolvers/institution.resolver';
|
||||
import { bundProjectsResolver } from './resolvers/bund-projects.resolver';
|
||||
import { euProjectsResolver } from './resolvers/eu-projects.resolver';
|
||||
import { dfgProjectsResolver } from './resolvers/dfg-projects.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: 'login',
|
||||
@@ -17,7 +16,7 @@ export const routes: Routes = [
|
||||
(mod) => mod.AppLoginComponent,
|
||||
),
|
||||
},
|
||||
{
|
||||
{
|
||||
path: 'register',
|
||||
loadComponent: () =>
|
||||
import('./modules/app-register/app-register.component').then(
|
||||
@@ -236,5 +235,6 @@ export const routes: Routes = [
|
||||
routeMessage:
|
||||
'Die gesuchte Seite existiert leider nicht oder wurde verschoben.',
|
||||
},
|
||||
canActivate: [userGuard],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, inject, OnDestroy, signal, DestroyRef } from '@angular/core';
|
||||
import { Component, inject, OnDestroy, signal, DestroyRef, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
@@ -36,7 +36,7 @@ import { InstitutionsService } from '../../api';
|
||||
templateUrl: './app-register.component.html',
|
||||
styleUrl: './app-register.component.scss',
|
||||
})
|
||||
export class AppRegisterComponent implements OnDestroy {
|
||||
export class AppRegisterComponent implements OnDestroy, OnInit {
|
||||
private readonly fb = inject(FormBuilder);
|
||||
protected readonly credentialService = inject(CredentialService);
|
||||
private readonly router = inject(Router);
|
||||
@@ -57,11 +57,30 @@ export class AppRegisterComponent implements OnDestroy {
|
||||
constructor() {
|
||||
this.setupInstitutionAutocomplete();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscription = this.credentialService.validating.subscribe(
|
||||
(validating) => {
|
||||
if (validating) {
|
||||
this.registerForm.disable();
|
||||
} else {
|
||||
this.registerForm.enable();
|
||||
this.checkEnter();
|
||||
}
|
||||
},
|
||||
);
|
||||
if (!this.credentialService.validating) {
|
||||
this.checkEnter();
|
||||
}
|
||||
}
|
||||
ngOnDestroy(): void {
|
||||
this.subscription?.unsubscribe();
|
||||
}
|
||||
|
||||
checkEnter(): void {
|
||||
if (this.credentialService.authenticated.value) {
|
||||
this.router.navigate(['/dashboard']);
|
||||
}
|
||||
}
|
||||
submit() {
|
||||
if (this.registerForm.valid) {
|
||||
this.credentialService.validating.next(true);
|
||||
|
||||
Reference in New Issue
Block a user