This commit is contained in:
Lurkars
2020-11-02 08:29:52 +01:00
commit b7b4e2d032
126 changed files with 18263 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AuthService } from './../../services/auth.service';
import { Router } from '@angular/router';
import { environment } from './../../../environments/environment';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
form: FormGroup;
public loginInvalid: boolean;
public apiUrl = environment.apiUrl;
loginModel = {};
constructor(private formBuilder: FormBuilder, private authService: AuthService, private router: Router) { }
async ngOnInit() {
this.form = this.formBuilder.group({
username: ['', Validators.required],
password: ['', Validators.required]
});
}
async login() {
this.loginInvalid = false;
if (this.form.valid) {
const username = this.form.get('username').value;
const password = this.form.get('password').value;
this.authService.login(username, password).subscribe((response: any) => {
this.router.navigate(["/account/info"]);
}, error => {
if (error.status == 302) {
console.log(error);
} else {
this.loginInvalid = true;
}
});
}
}
}