diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index d1770a0c29..4d577811ed 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -32,7 +32,8 @@ import { UsersComponent } from './system/users/users.component'; const routes: Routes = [ { path: '', - component: MainComponent + component: LoginComponent + // component: MainComponent }, { path: 'help', diff --git a/src/app/main/login/login.component.ts b/src/app/main/login/login.component.ts index d4122147bc..431b0884f1 100644 --- a/src/app/main/login/login.component.ts +++ b/src/app/main/login/login.component.ts @@ -1,6 +1,7 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; +import { SessionService } from '@dasch-swiss/dsp-ui'; import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service'; @Component({ @@ -8,29 +9,28 @@ import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/m templateUrl: './login.component.html', styleUrls: ['./login.component.scss'] }) -export class LoginComponent implements OnInit { +export class LoginComponent { returnUrl: string; constructor (private _titleService: Title, private _route: ActivatedRoute, private _router: Router, + private _session: SessionService, private _componentCommsService: ComponentCommunicationEventService) { // set the page title this._titleService.setTitle('Login'); - this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/'; - } - - ngOnInit() { + // this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/'; } refresh(status: boolean) { - // go to previous route: - if (status) { - this._router.navigate([this.returnUrl]); + // go to the dashboard: + if (status && this._session.getSession()) { + this._router.navigate(['dashboard']); + // go to the previous route: this._router.navigate([this.returnUrl]); this._componentCommsService.emit(new EmitEvent(Events.LoginSuccess, true)); } }