blob: 79a788de35398a2008ce173a4fa99961f46709b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { InternalUserService } from '../internal-user-service/internal-user.service';
export type LoginMessage = 'nologin' | 'invalidlogin' | string;
@Component({
selector: 'app-user-login',
templateUrl: './user-login.component.html',
styleUrls: ['./user-login.component.css']
})
export class UserLoginComponent implements OnInit {
constructor(private route: ActivatedRoute, private userService: InternalUserService) { }
message: LoginMessage;
form = new FormGroup({
username: new FormControl(''),
password: new FormControl('')
});
ngOnInit() {
this.message = this.route.snapshot.paramMap.get('reason');
}
onLoginButtonClick() {
this.userService.tryLogin(this.form.value).subscribe(_ => {
this.userService.userRouteNavigate(['success', { reason: 'login' }]);
}, (error: Error) => this.message = error.message);
}
}
|