import { Component, OnInit } from '@angular/core';
-import { Router } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
+import * as _ from 'lodash';
import { BsModalService } from 'ngx-bootstrap/modal';
import { AuthService } from '../../../shared/api/auth.service';
export class LoginComponent implements OnInit {
model = new Credentials();
isLoginActive = false;
+ returnUrl: string;
constructor(
private authService: AuthService,
private authStorageService: AuthStorageService,
private bsModalService: BsModalService,
+ private route: ActivatedRoute,
private router: Router
) {}
login() {
this.authService.login(this.model).subscribe(() => {
- this.router.navigate(['']);
+ const url = _.get(this.route.snapshot.queryParams, 'returnUrl', '/');
+ this.router.navigate([url]);
});
}
}