Qq fix pour corriger la page de login
This commit is contained in:
@@ -1,4 +1,30 @@
|
|||||||
<form
|
<form
|
||||||
|
focusInvalidInput
|
||||||
|
autocomplete="off"
|
||||||
|
style="padding: 10px"
|
||||||
|
(ngSubmit)="onCreateSubmit()"
|
||||||
|
[formGroup]="createForm"
|
||||||
|
>
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label>{{ "LoginCreateUser_Firstname" | translate }}</mat-label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
matInput
|
||||||
|
#firstname="matInput"
|
||||||
|
formControlName="firstname"
|
||||||
|
[ngClass]="{ 'is-invalid': submitted && formCtrls['firstname'].errors }"
|
||||||
|
tabindex="0"
|
||||||
|
/>
|
||||||
|
<mat-error *ngIf="formCtrls['firstname'].hasError('required')">
|
||||||
|
{{ "LoginCreateUser_FirstnameRequired" | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="formCtrls['firstname'].hasError('minlength')">
|
||||||
|
{{ "LoginCreateUser_FirstnamePattern" | translate }}
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- <form
|
||||||
[formGroup]="createForm"
|
[formGroup]="createForm"
|
||||||
(ngSubmit)="onCreateSubmit()"
|
(ngSubmit)="onCreateSubmit()"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
@@ -7,7 +33,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{ "LoginCreateUser_Firstname" | translate }}</mat-label>
|
<mat-label>{{ "LoginCreateUser_Firstname" | translate }}</mat-label>
|
||||||
<!-- <input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="text"
|
type="text"
|
||||||
formControlName="firstname"
|
formControlName="firstname"
|
||||||
@@ -19,13 +45,13 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="formCtrls['firstname'].hasError('minlength')">
|
<mat-error *ngIf="formCtrls['firstname'].hasError('minlength')">
|
||||||
{{ "LoginCreateUser_FirstnamePattern" | translate }}
|
{{ "LoginCreateUser_FirstnamePattern" | translate }}
|
||||||
</mat-error> -->
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{ "LoginCreateUser_Lastname" | translate }}</mat-label>
|
<mat-label>{{ "LoginCreateUser_Lastname" | translate }}</mat-label>
|
||||||
<!-- <input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="text"
|
type="text"
|
||||||
formControlName="lastname"
|
formControlName="lastname"
|
||||||
@@ -37,13 +63,13 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="formCtrls['lastname'].hasError('minlength')">
|
<mat-error *ngIf="formCtrls['lastname'].hasError('minlength')">
|
||||||
{{ "LoginCreateUser_LastnamePattern" | translate }}
|
{{ "LoginCreateUser_LastnamePattern" | translate }}
|
||||||
</mat-error> -->
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{ "LoginCreateUser_Email" | translate }}</mat-label>
|
<mat-label>{{ "LoginCreateUser_Email" | translate }}</mat-label>
|
||||||
<!-- <input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="email"
|
type="email"
|
||||||
formControlName="email"
|
formControlName="email"
|
||||||
@@ -55,13 +81,13 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="formCtrls['email'].hasError('email')">
|
<mat-error *ngIf="formCtrls['email'].hasError('email')">
|
||||||
{{ "LoginCreateUser_EmailPattern" | translate }}
|
{{ "LoginCreateUser_EmailPattern" | translate }}
|
||||||
</mat-error> -->
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{ "LoginCreateUser_Username" | translate }}</mat-label>
|
<mat-label>{{ "LoginCreateUser_Username" | translate }}</mat-label>
|
||||||
<!-- <input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="text"
|
type="text"
|
||||||
formControlName="username"
|
formControlName="username"
|
||||||
@@ -73,13 +99,13 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="formCtrls['username'].hasError('minlength')">
|
<mat-error *ngIf="formCtrls['username'].hasError('minlength')">
|
||||||
{{ "LoginCreateUser_UsernamePattern" | translate }}
|
{{ "LoginCreateUser_UsernamePattern" | translate }}
|
||||||
</mat-error> -->
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>{{ "LoginCreateUser_Password" | translate }}</mat-label>
|
<mat-label>{{ "LoginCreateUser_Password" | translate }}</mat-label>
|
||||||
<!-- <input
|
<input
|
||||||
matInput
|
matInput
|
||||||
type="password"
|
type="password"
|
||||||
formControlName="password"
|
formControlName="password"
|
||||||
@@ -91,7 +117,7 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="formCtrls['password'].hasError('pattern')">
|
<mat-error *ngIf="formCtrls['password'].hasError('pattern')">
|
||||||
{{ "LoginCreateUser_PasswordPattern" | translate }}
|
{{ "LoginCreateUser_PasswordPattern" | translate }}
|
||||||
</mat-error> -->
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -99,4 +125,4 @@
|
|||||||
{{ "LoginCreateUser_BtnLogin" | translate }}
|
{{ "LoginCreateUser_BtnLogin" | translate }}
|
||||||
</button>
|
</button>
|
||||||
<div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{ error }}</div>
|
<div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{ error }}</div>
|
||||||
</form>
|
</form> -->
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit, ViewChild } from "@angular/core";
|
||||||
import { Router, ActivatedRoute } from "@angular/router";
|
import { Router, ActivatedRoute } from "@angular/router";
|
||||||
import {
|
import {
|
||||||
FormBuilder,
|
FormBuilder,
|
||||||
@@ -18,6 +18,7 @@ import { first } from "rxjs/operators";
|
|||||||
|
|
||||||
import { AuthenticationService } from "../../services/authentication.service";
|
import { AuthenticationService } from "../../services/authentication.service";
|
||||||
import { User } from "../../models/user";
|
import { User } from "../../models/user";
|
||||||
|
import { MatInput, MatInputModule } from "@angular/material/input";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-create-user",
|
selector: "app-create-user",
|
||||||
@@ -27,16 +28,18 @@ import { User } from "../../models/user";
|
|||||||
CommonModule,
|
CommonModule,
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
|
MatInputModule,
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
TranslatePipe,
|
TranslatePipe,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CreateUserComponent implements OnInit {
|
export class CreateUserComponent implements OnInit {
|
||||||
createForm: FormGroup;
|
public createForm: FormGroup;
|
||||||
invalidForm = true;
|
public invalidForm = true;
|
||||||
submitted = false;
|
public submitted = false;
|
||||||
returnUrl: string;
|
public returnUrl: string;
|
||||||
error = "";
|
public error: string = "";
|
||||||
|
@ViewChild("firstname") firstnameInput: MatInput;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
@@ -51,22 +54,26 @@ export class CreateUserComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.firstnameInput.focus();
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.createForm = this.formBuilder.group(
|
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)]],
|
firstname: ["", [Validators.required, Validators.minLength(3)]],
|
||||||
lastname: ["", [Validators.required, Validators.minLength(3)]],
|
// username: ["", [Validators.required, Validators.minLength(3)]],
|
||||||
email: ["", [Validators.required, Validators.email]],
|
// 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" }
|
{ updateOn: "blur" }
|
||||||
);
|
);
|
||||||
@@ -80,33 +87,28 @@ export class CreateUserComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCreateSubmit() {
|
onCreateSubmit() {
|
||||||
this.invalidForm = false;
|
// this.invalidForm = false;
|
||||||
this.submitted = true;
|
// this.submitted = true;
|
||||||
|
// if (this.createForm.invalid) {
|
||||||
if (this.createForm.invalid) {
|
// this.invalidForm = true;
|
||||||
this.invalidForm = true;
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
// let createUser = new User();
|
||||||
|
// createUser.login = this.formCtrls["username"].value;
|
||||||
let createUser = new User();
|
// createUser.password = this.formCtrls["password"].value;
|
||||||
createUser.login = this.formCtrls["username"].value;
|
// createUser.firstName = this.formCtrls["firstname"].value;
|
||||||
createUser.password = this.formCtrls["password"].value;
|
// createUser.lastName = this.formCtrls["lastname"].value;
|
||||||
createUser.firstName = this.formCtrls["firstname"].value;
|
// createUser.email = this.formCtrls["email"].value;
|
||||||
createUser.lastName = this.formCtrls["lastname"].value;
|
// createUser.language = this.translateService.getCurrentLang();
|
||||||
createUser.email = this.formCtrls["email"].value;
|
// this.authenticationService
|
||||||
createUser.language = this.translateService.getCurrentLang();
|
// .create(createUser)
|
||||||
|
// .pipe(first())
|
||||||
this.authenticationService
|
// .subscribe({
|
||||||
.create(createUser)
|
// complete: () => this.router.navigate([this.returnUrl]),
|
||||||
.pipe(first())
|
// error: (error) => {
|
||||||
.subscribe(
|
// this.error = error.message;
|
||||||
(data) => {
|
// this.invalidForm = false;
|
||||||
this.router.navigate([this.returnUrl]);
|
// },
|
||||||
},
|
// });
|
||||||
(error) => {
|
|
||||||
this.error = error;
|
|
||||||
this.invalidForm = false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ import { AuthenticationService } from "../../services/authentication.service";
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class LoginUserComponent implements OnInit, AfterViewInit {
|
export class LoginUserComponent implements OnInit, AfterViewInit {
|
||||||
loginForm: FormGroup;
|
public loginForm: FormGroup;
|
||||||
loading = false;
|
public loading = false;
|
||||||
submitted = false;
|
public submitted = false;
|
||||||
returnUrl: string;
|
public returnUrl: string;
|
||||||
error = "";
|
public error: string = "";
|
||||||
@ViewChild("username") userNameInput: MatInput;
|
@ViewChild("username") userNameInput: MatInput;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -68,7 +68,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
|||||||
return this.loginForm.controls;
|
return this.loginForm.controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoginSubmit() {
|
public onLoginSubmit() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
|
|
||||||
if (this.loginForm.valid) {
|
if (this.loginForm.valid) {
|
||||||
@@ -79,15 +79,13 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
|
|||||||
this.formCtrls["password"].value
|
this.formCtrls["password"].value
|
||||||
)
|
)
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.subscribe(
|
.subscribe({
|
||||||
(data) => {
|
complete: () => this.router.navigate([this.returnUrl]),
|
||||||
this.router.navigate([this.returnUrl]);
|
error: (error) => {
|
||||||
},
|
this.error = error.message;
|
||||||
(error) => {
|
|
||||||
this.error = error;
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
},
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,5 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<mat-select
|
<mat-card style="max-width: 500px" flex="50">
|
||||||
(selectionChange)="switchLang($event)"
|
|
||||||
[(value)]="selectedLanguageFlag"
|
|
||||||
style="width: 60px; padding-left: 30px"
|
|
||||||
>
|
|
||||||
<mat-select-trigger>
|
|
||||||
<img
|
|
||||||
src="{{ 'assets/img/' + selectedLanguageFlag + '.svg' }}"
|
|
||||||
style="width: 30px"
|
|
||||||
/>
|
|
||||||
</mat-select-trigger>
|
|
||||||
<mat-option value="fr">
|
|
||||||
<img src="assets/img/fr.svg" style="width: 30px" />
|
|
||||||
</mat-option>
|
|
||||||
<mat-option value="en">
|
|
||||||
<img src="assets/img/en.svg" style="width: 30px" />
|
|
||||||
</mat-option>
|
|
||||||
</mat-select>
|
|
||||||
<app-create-user></app-create-user>
|
|
||||||
|
|
||||||
<!-- <mat-card style="max-width: 500px" flex="50">
|
|
||||||
<mat-card-header
|
<mat-card-header
|
||||||
style="
|
style="
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -59,5 +39,5 @@
|
|||||||
</mat-tab>
|
</mat-tab>
|
||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card> -->
|
</mat-card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user