diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-15 17:28:01 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-15 17:28:01 -0400 |
commit | 51f0322db803ed3baf1f24f18a6e7a83dab58a3b (patch) | |
tree | f252383812cf1131199fa147feb0eca7639b520a /ufund-ui/src/app/components/login/login.component.ts | |
parent | 4f2f1d0944b15ced834255cd2934516a953b97a5 (diff) | |
download | JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.tar.gz JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.tar.bz2 JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.zip |
Add login redirection
Diffstat (limited to '')
-rw-r--r-- | ufund-ui/src/app/components/login/login.component.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/ufund-ui/src/app/components/login/login.component.ts b/ufund-ui/src/app/components/login/login.component.ts index 50dd018..7d90624 100644 --- a/ufund-ui/src/app/components/login/login.component.ts +++ b/ufund-ui/src/app/components/login/login.component.ts @@ -1,6 +1,6 @@ -import { Component } from '@angular/core' +import {Component, OnInit} from '@angular/core' import {UsersService} from '../../services/users.service'; -import {Router} from '@angular/router'; +import {ActivatedRoute, Router} from '@angular/router'; @Component({ selector: 'app-login', @@ -8,20 +8,29 @@ import {Router} from '@angular/router'; templateUrl: './login.component.html', styleUrl: './login.component.css' }) -export class LoginComponent { +export class LoginComponent implements OnInit { + + protected next?: string | null; + constructor( protected usersService: UsersService, - private router: Router + private router: Router, + private route: ActivatedRoute ) {} + ngOnInit() { + this.next = this.route.snapshot.queryParamMap.get('redir') + } + login(username: string | null, password: string | null) { + let next = this.next || '/dashboard' console.log(`attempting to log in with ${username} ${password}`) if (!username || !password) { return; } this.usersService.login(username, password).then(() => { - this.router.navigate(['/dashboard']); + this.router.navigate([next]); }) } } |