1- import { AfterViewInit , Component , OnInit } from '@angular/core' ;
1+ import { Component , OnInit } from '@angular/core' ;
22import { FormBuilder , FormGroup , Validators } from '@angular/forms' ;
33import { DomSanitizer } from '@angular/platform-browser' ;
44import { ActivatedRoute , Router } from '@angular/router' ;
@@ -14,6 +14,7 @@ import {ThemeChangeBehavior} from '../../../behaviors/theme-change.behavior';
1414import { ADMIN_DEFAULT_EMAIL , ADMIN_ROLE , DEMO_URL , USER_ROLE } from '../../../constants/global.constant' ;
1515import { stringParamToQueryParams } from '../../../util/query-params-to-filter.util' ;
1616import { PasswordResetInitComponent } from '../password-reset/init/password-reset-init.component' ;
17+ import { StateStorageService } from "../../../../core/auth/state-storage.service" ;
1718
1819@Component ( {
1920 selector : 'app-login' ,
@@ -48,7 +49,8 @@ export class LoginComponent implements OnInit {
4849 private modalService : NgbModal ,
4950 private themeChangeBehavior : ThemeChangeBehavior ,
5051 private spinner : NgxSpinnerService ,
51- private apiServiceCheckerService : ApiServiceCheckerService
52+ private apiServiceCheckerService : ApiServiceCheckerService ,
53+ private stateStorageService : StateStorageService
5254 ) {
5355 this . credentials = { } ;
5456 this . isInDemo = window . location . href . includes ( DEMO_URL ) ;
@@ -166,8 +168,9 @@ export class LoginComponent implements OnInit {
166168 startNavigation ( ) {
167169 this . accountService . identity ( true ) . then ( account => {
168170 if ( account ) {
171+ const url = this . stateStorageService . getUrl ( ) ;
169172 const redirectTo = ( account . authorities . includes ( ADMIN_ROLE ) && account . email === ADMIN_DEFAULT_EMAIL )
170- ? '/getting-started' : '/dashboard/overview' ;
173+ ? '/getting-started' : ! ! url ? url : '/dashboard/overview' ;
171174 this . router . navigate ( [ redirectTo ] )
172175 . then ( ( ) => this . spinner . hide ( ) ) ;
173176 } else {
0 commit comments