import {Component, OnInit} from '@angular/core' import {UsersService} from '../../services/users.service'; import {ActivatedRoute, Router} from '@angular/router'; @Component({ selector: 'app-login', standalone: false, templateUrl: './login.component.html', styleUrl: './login.component.css' }) export class LoginComponent implements OnInit { protected next?: string | null; constructor( protected usersService: UsersService, 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([next]); }) } }