Skip to content

Commit 46dfdbb

Browse files
flavensflaurens
andauthored
refactor!: set up the login page as a starting page (DSP-1292) (#370)
* refactor(login): set login page as the landing page + redirect to the dashboard * refactor(login): remove argument * doc(login): add comment * refactor(login): reverse previous change in html * refactor(login): refactor refresh method + clean up Co-authored-by: flaurens <flavie.laurens@unibas.ch>
1 parent 50b1309 commit 46dfdbb

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎src/app/app-routing.module.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import { UsersComponent } from './system/users/users.component';
3232
const routes: Routes = [
3333
{
3434
path: '',
35-
component: MainComponent
35+
component: LoginComponent
36+
// component: MainComponent
3637
},
3738
{
3839
path: 'help',

‎src/app/main/login/login.component.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { Title } from '@angular/platform-browser';
33
import { ActivatedRoute, Router } from '@angular/router';
4+
import { SessionService } from '@dasch-swiss/dsp-ui';
45
import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service';
56

67
@Component({
78
selector: 'app-login',
89
templateUrl: './login.component.html',
910
styleUrls: ['./login.component.scss']
1011
})
11-
export class LoginComponent implements OnInit {
12+
export class LoginComponent {
1213

1314
returnUrl: string;
1415

1516
constructor (private _titleService: Title,
1617
private _route: ActivatedRoute,
1718
private _router: Router,
19+
private _session: SessionService,
1820
private _componentCommsService: ComponentCommunicationEventService) {
1921

2022
// set the page title
2123
this._titleService.setTitle('Login');
2224

23-
this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/';
24-
}
25-
26-
ngOnInit() {
25+
// this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/';
2726
}
2827

2928
refresh(status: boolean) {
3029

31-
// go to previous route:
32-
if (status) {
33-
this._router.navigate([this.returnUrl]);
30+
// go to the dashboard:
31+
if (status && this._session.getSession()) {
32+
this._router.navigate(['dashboard']);
33+
// go to the previous route: this._router.navigate([this.returnUrl]);
3434
this._componentCommsService.emit(new EmitEvent(Events.LoginSuccess, true));
3535
}
3636
}

0 commit comments

Comments
 (0)