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 | |
| parent | 4f2f1d0944b15ced834255cd2934516a953b97a5 (diff) | |
| download | JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.tar.gz JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.tar.bz2 JellySolutions-51f0322db803ed3baf1f24f18a6e7a83dab58a3b.zip  | |
Add login redirection
Diffstat (limited to 'ufund-ui/src/app/components/login')
| -rw-r--r-- | ufund-ui/src/app/components/login/login.component.html | 1 | ||||
| -rw-r--r-- | ufund-ui/src/app/components/login/login.component.ts | 19 | 
2 files changed, 15 insertions, 5 deletions
diff --git a/ufund-ui/src/app/components/login/login.component.html b/ufund-ui/src/app/components/login/login.component.html index 178ddbf..bfd7f5e 100644 --- a/ufund-ui/src/app/components/login/login.component.html +++ b/ufund-ui/src/app/components/login/login.component.html @@ -1,3 +1,4 @@ +<div *ngIf="next" style="color: red">You must be logged in to view this page</div>  <p>Login:</p>  <input placeholder="Username" type="text" #username>  <input placeholder="Password" type="password" #password> 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]);          })      }  }  | 
