From 73043aa7ce4a8e68390a9959d09977ec1bfbed0f Mon Sep 17 00:00:00 2001 From: sandre Date: Thu, 15 Jan 2026 16:26:36 +0100 Subject: [PATCH] Qq fix pour corriger la page de login --- .../create-user/create-user.component.html | 48 +++++++--- .../app/create-user/create-user.component.ts | 94 ++++++++++--------- .../app/login-user/login-user.component.ts | 26 +++-- .../src/app/login/login.component.html | 24 +---- 4 files changed, 99 insertions(+), 93 deletions(-) diff --git a/Front/skydivelogs-app/src/app/create-user/create-user.component.html b/Front/skydivelogs-app/src/app/create-user/create-user.component.html index 162541d..0487fb3 100644 --- a/Front/skydivelogs-app/src/app/create-user/create-user.component.html +++ b/Front/skydivelogs-app/src/app/create-user/create-user.component.html @@ -1,4 +1,30 @@
+ + {{ "LoginCreateUser_Firstname" | translate }} + + + {{ "LoginCreateUser_FirstnameRequired" | translate }} + + + {{ "LoginCreateUser_FirstnamePattern" | translate }} + + +
+ + +

{{ "LoginCreateUser_Lastname" | translate }} - +

{{ "LoginCreateUser_Email" | translate }} - +

{{ "LoginCreateUser_Username" | translate }} - +

{{ "LoginCreateUser_Password" | translate }} - +

@@ -99,4 +125,4 @@ {{ "LoginCreateUser_BtnLogin" | translate }}
{{ error }}
- + --> diff --git a/Front/skydivelogs-app/src/app/create-user/create-user.component.ts b/Front/skydivelogs-app/src/app/create-user/create-user.component.ts index aaa10c8..cc4bd0f 100644 --- a/Front/skydivelogs-app/src/app/create-user/create-user.component.ts +++ b/Front/skydivelogs-app/src/app/create-user/create-user.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from "@angular/core"; +import { Component, OnInit, ViewChild } from "@angular/core"; import { Router, ActivatedRoute } from "@angular/router"; import { FormBuilder, @@ -18,6 +18,7 @@ import { first } from "rxjs/operators"; import { AuthenticationService } from "../../services/authentication.service"; import { User } from "../../models/user"; +import { MatInput, MatInputModule } from "@angular/material/input"; @Component({ selector: "app-create-user", @@ -27,16 +28,18 @@ import { User } from "../../models/user"; CommonModule, MatFormFieldModule, ReactiveFormsModule, + MatInputModule, TranslateModule, TranslatePipe, ], }) export class CreateUserComponent implements OnInit { - createForm: FormGroup; - invalidForm = true; - submitted = false; - returnUrl: string; - error = ""; + public createForm: FormGroup; + public invalidForm = true; + public submitted = false; + public returnUrl: string; + public error: string = ""; + @ViewChild("firstname") firstnameInput: MatInput; constructor( private formBuilder: FormBuilder, @@ -51,22 +54,26 @@ export class CreateUserComponent implements OnInit { } } + ngAfterViewInit() { + this.firstnameInput.focus(); + } + ngOnInit() { this.createForm = this.formBuilder.group( { - username: ["", [Validators.required, Validators.minLength(3)]], - password: [ - "", - [ - Validators.required, - Validators.pattern( - "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[@$!%*#?&-_|]).{8,}$" - ), - ], - ], firstname: ["", [Validators.required, Validators.minLength(3)]], - lastname: ["", [Validators.required, Validators.minLength(3)]], - email: ["", [Validators.required, Validators.email]], + // username: ["", [Validators.required, Validators.minLength(3)]], + // password: [ + // "", + // [ + // Validators.required, + // Validators.pattern( + // "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[@$!%*#?&-_|]).{8,}$" + // ), + // ], + // ], + // lastname: ["", [Validators.required, Validators.minLength(3)]], + // email: ["", [Validators.required, Validators.email]], }, { updateOn: "blur" } ); @@ -80,33 +87,28 @@ export class CreateUserComponent implements OnInit { } onCreateSubmit() { - this.invalidForm = false; - this.submitted = true; - - if (this.createForm.invalid) { - this.invalidForm = true; - return; - } - - let createUser = new User(); - createUser.login = this.formCtrls["username"].value; - createUser.password = this.formCtrls["password"].value; - createUser.firstName = this.formCtrls["firstname"].value; - createUser.lastName = this.formCtrls["lastname"].value; - createUser.email = this.formCtrls["email"].value; - createUser.language = this.translateService.getCurrentLang(); - - this.authenticationService - .create(createUser) - .pipe(first()) - .subscribe( - (data) => { - this.router.navigate([this.returnUrl]); - }, - (error) => { - this.error = error; - this.invalidForm = false; - } - ); + // this.invalidForm = false; + // this.submitted = true; + // if (this.createForm.invalid) { + // this.invalidForm = true; + // return; + // } + // let createUser = new User(); + // createUser.login = this.formCtrls["username"].value; + // createUser.password = this.formCtrls["password"].value; + // createUser.firstName = this.formCtrls["firstname"].value; + // createUser.lastName = this.formCtrls["lastname"].value; + // createUser.email = this.formCtrls["email"].value; + // createUser.language = this.translateService.getCurrentLang(); + // this.authenticationService + // .create(createUser) + // .pipe(first()) + // .subscribe({ + // complete: () => this.router.navigate([this.returnUrl]), + // error: (error) => { + // this.error = error.message; + // this.invalidForm = false; + // }, + // }); } } diff --git a/Front/skydivelogs-app/src/app/login-user/login-user.component.ts b/Front/skydivelogs-app/src/app/login-user/login-user.component.ts index fcac924..43496ca 100644 --- a/Front/skydivelogs-app/src/app/login-user/login-user.component.ts +++ b/Front/skydivelogs-app/src/app/login-user/login-user.component.ts @@ -29,11 +29,11 @@ import { AuthenticationService } from "../../services/authentication.service"; ], }) export class LoginUserComponent implements OnInit, AfterViewInit { - loginForm: FormGroup; - loading = false; - submitted = false; - returnUrl: string; - error = ""; + public loginForm: FormGroup; + public loading = false; + public submitted = false; + public returnUrl: string; + public error: string = ""; @ViewChild("username") userNameInput: MatInput; constructor( @@ -68,7 +68,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit { return this.loginForm.controls; } - onLoginSubmit() { + public onLoginSubmit() { this.submitted = true; if (this.loginForm.valid) { @@ -79,15 +79,13 @@ export class LoginUserComponent implements OnInit, AfterViewInit { this.formCtrls["password"].value ) .pipe(first()) - .subscribe( - (data) => { - this.router.navigate([this.returnUrl]); - }, - (error) => { - this.error = error; + .subscribe({ + complete: () => this.router.navigate([this.returnUrl]), + error: (error) => { + this.error = error.message; this.loading = false; - } - ); + }, + }); } } } diff --git a/Front/skydivelogs-app/src/app/login/login.component.html b/Front/skydivelogs-app/src/app/login/login.component.html index b67e8b4..f712a7a 100644 --- a/Front/skydivelogs-app/src/app/login/login.component.html +++ b/Front/skydivelogs-app/src/app/login/login.component.html @@ -1,25 +1,5 @@
- - - - - - - - - - - - - - +