#2962 IPAd Login Fix

This commit is contained in:
Lorenz Hilpert
2022-04-04 13:43:17 +02:00
parent 8145436d1d
commit 6ff4d204c2
8 changed files with 107 additions and 65 deletions

View File

@@ -16,8 +16,13 @@ import {
} from './guards';
import { BranchSectionResolver, CustomerSectionResolver, ProcessIdResolver } from './resolvers';
import { ShellComponent, ShellModule } from './shell';
import { TokenLoginComponent, TokenLoginModule } from './token-login';
const routes: Routes = [
{
path: 'login',
children: [{ path: ':token', component: TokenLoginComponent }],
},
{
path: '',
canActivate: [IsAuthenticatedGuard],
@@ -107,7 +112,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forRoot(routes), ShellModule],
imports: [RouterModule.forRoot(routes), ShellModule, TokenLoginModule],
exports: [RouterModule],
})
export class AppRoutingModule {}

View File

@@ -0,0 +1,2 @@
export * from './token-login.component';
export * from './token-login.module';

View File

View File

View File

@@ -0,0 +1,22 @@
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthService } from '@core/auth';
@Component({
selector: 'app-token-login',
templateUrl: 'token-login.component.html',
styleUrls: ['token-login.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TokenLoginComponent implements OnInit {
constructor(private _route: ActivatedRoute, private _authService: AuthService, private _router: Router) {}
ngOnInit() {
if (this._route.snapshot.params.token && !this._authService.isAuthenticated()) {
this._authService.setKeyCardToken(this._route.snapshot.params.token);
this._authService.login();
} else {
this._router.navigate(['/']);
}
}
}

View File

@@ -0,0 +1,11 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TokenLoginComponent } from './token-login.component';
@NgModule({
imports: [CommonModule],
exports: [TokenLoginComponent],
declarations: [TokenLoginComponent],
})
export class TokenLoginModule {}