diff --git a/angular.json b/angular.json
index 21f2bb7..7d84a59 100644
--- a/angular.json
+++ b/angular.json
@@ -30,8 +30,8 @@
"budgets": [
{
"type": "initial",
- "maximumWarning": "500kb",
- "maximumError": "1mb"
+ "maximumWarning": "2mb",
+ "maximumError": "3mb"
},
{
"type": "anyComponentStyle",
diff --git a/src/app/components/login/login.component.html b/src/app/components/login/login.component.html
index 23dd3c1..ef40f05 100644
--- a/src/app/components/login/login.component.html
+++ b/src/app/components/login/login.component.html
@@ -1,43 +1,33 @@
-
+ {{ errorLogin }}
+ {{ successLogin }}
+
diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts
index 92857b8..4e8dc92 100644
--- a/src/app/components/login/login.component.ts
+++ b/src/app/components/login/login.component.ts
@@ -6,6 +6,8 @@ import {
FormsModule,
ReactiveFormsModule,
NgForm,
+ FormGroup,
+ FormBuilder,
} from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
@@ -34,41 +36,37 @@ import { User } from 'src/app/models/user.model';
export class LoginComponent {
hide = true;
- email = new FormControl('', [Validators.required, Validators.email]);
-
- login = new FormControl('', [Validators.required]);
-
- password = new FormControl('', [Validators.required]);
+ loginForm = this.formBuilder.group({
+ login: ['', Validators.required],
+ password: ['', Validators.required],
+ });
errorMessage = '';
successLogin = '';
errorLogin = '';
- constructor(private userService: UserService) {
- merge(this.email.statusChanges, this.email.valueChanges).pipe(
- takeUntilDestroyed()
- );
+ constructor(
+ private userService: UserService,
+ private formBuilder: FormBuilder
+ ) {
+ this.userService = userService;
}
loginAction() {
- console.log('login user :', this.login.value);
+ const formValue = this.loginForm.value;
- const form: any = {
- value: {
- login: this.login.value,
- password: this.password.value,
- },
- };
- this.userService.loginUser(form).subscribe((response) => {
- console.log('response :', response);
- if ((response as any).success) {
- this.successLogin = 'Vous êtes connecté.';
- this.errorLogin = '';
- } else {
- this.errorLogin = "L'authentification a échoué.";
- this.successLogin = '';
- }
- });
+ this.userService
+ .loginUser(formValue.login!, formValue.password!)
+ .subscribe((response) => {
+ console.log('response :', response);
+ if (response.success) {
+ this.successLogin = 'Vous êtes connecté.';
+ this.errorLogin = '';
+ } else {
+ this.errorLogin = "L'authentification a échoué.";
+ this.successLogin = '';
+ }
+ });
}
}
diff --git a/src/app/components/register/register.component.html b/src/app/components/register/register.component.html
index f76e7e7..1c3bf41 100644
--- a/src/app/components/register/register.component.html
+++ b/src/app/components/register/register.component.html
@@ -1,4 +1,4 @@
-