Ajout Login et Register #14

Merged
clement.freville2 merged 11 commits from form-login-register into master 5 months ago
Owner
There is no content yet.
hugo.pradier2 added 3 commits 5 months ago
continuous-integration/drone/push Build is failing Details
f6d28150c9
verif des champs avant inscription
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/pr Build is failing Details
30397b994c
ajout login fonctionnel
hugo.pradier2 requested review from clement.freville2 5 months ago
clement.freville2 requested changes 5 months ago
clement.freville2 left a comment
Owner

Do not commit a .nx directory.

Do not commit a `.nx` directory.
export class LoginComponent {
hide = true;
email = new FormControl('', [Validators.required, Validators.email]);

This field is never used in the login template.

This field is never used in the login template.
Poster
Owner

Si je l'utilise pour afficher ou non le mot de passe

Si je l'utilise pour afficher ou non le mot de passe
clement.freville2 marked this conversation as resolved
.subscribe(() => this.updateErrorMessage());
}
updateErrorMessage() {

Validators must only exist in FormControl, do not try to duplicate this behavior.

Validators must only exist in `FormControl`, do not try to duplicate this behavior.
clement.freville2 marked this conversation as resolved
<div class="form-container">
-<div class="form-container">
+<form [formGroup]="form">

https://angular.dev/guide/forms/reactive-forms

```diff -<div class="form-container"> +<form [formGroup]="form"> ``` https://angular.dev/guide/forms/reactive-forms
clement.freville2 marked this conversation as resolved
mat-flat-button
color="primary"
(click)="register()"
[disabled]="email.invalid || login.invalid || password.invalid">
-    [disabled]="email.invalid || login.invalid || password.invalid">
+    [disabled]="form.invalid">
```diff - [disabled]="email.invalid || login.invalid || password.invalid"> + [disabled]="form.invalid"> ```
clement.freville2 marked this conversation as resolved
login = new FormControl('', [Validators.required]);
password = new FormControl('', [Validators.required]);
-  email = new FormControl('', [Validators.required, Validators.email]);
-
-  login = new FormControl('', [Validators.required]);
-
-  password = new FormControl('', [Validators.required]);
+  form = this.formBuilder.group({
+    email: ['', Validators.required, Validators.email],
+    login: ['', Validators.required],
+    password: ['', Validators.required],
+  });
```diff - email = new FormControl('', [Validators.required, Validators.email]); - - login = new FormControl('', [Validators.required]); - - password = new FormControl('', [Validators.required]); + form = this.formBuilder.group({ + email: ['', Validators.required, Validators.email], + login: ['', Validators.required], + password: ['', Validators.required], + }); ```
clement.freville2 marked this conversation as resolved
export class UserService {
API_URL = 'http://127.0.0.1:3000';
private Users: User[] = [];
-  private Users: User[] = [];
```diff - private Users: User[] = []; ```
clement.freville2 marked this conversation as resolved
getUsers(): Observable<any> {
return this.http.get(`${this.API_URL}/Users`);
}
-  getUsers(): Observable<any> {
-    return this.http.get(`${this.API_URL}/Users`);
-  }
```diff - getUsers(): Observable<any> { - return this.http.get(`${this.API_URL}/Users`); - } ```
clement.freville2 marked this conversation as resolved
permissions: 0,
};
return this.http.post<any>(`${this.API_URL}/users`, body);
-  postUser(form: NgForm): Observable<HttpResponse<Response>> {
-    let body = {
-      login: form.value.login,
-      password: form.value.password,
-      permissions: 0,
+  postUser(login: string, password: string): Observable<Response> {
+    const body = {
+      login,
+      password,
     };
 
-    return this.http.post<any>(`${this.API_URL}/users`, body);
+    return this.http.post<Response>(`${this.API_URL}/users`, body);

No permissions should appear here, or your application would not be very secure.

```diff - postUser(form: NgForm): Observable<HttpResponse<Response>> { - let body = { - login: form.value.login, - password: form.value.password, - permissions: 0, + postUser(login: string, password: string): Observable<Response> { + const body = { + login, + password, }; - return this.http.post<any>(`${this.API_URL}/users`, body); + return this.http.post<Response>(`${this.API_URL}/users`, body); ``` No permissions should appear here, or your application would not be very secure.
clement.freville2 marked this conversation as resolved
};
return this.http.post<any>(`${this.API_URL}/users/login`, body);
}
-  loginUser(form: NgForm): Observable<HttpResponse<Response>> {
-    let body = {
-      login: form.value.login,
-      password: form.value.password,
+  loginUser(login: string, password: string): Observable<Response> {
+    const body = {
+      login,
+      password,
     };
 
-    return this.http.post<any>(`${this.API_URL}/users/login`, body);
+    return this.http.post<Response>(`${this.API_URL}/users/login`, body);

Never take NgForm in a service.

```diff - loginUser(form: NgForm): Observable<HttpResponse<Response>> { - let body = { - login: form.value.login, - password: form.value.password, + loginUser(login: string, password: string): Observable<Response> { + const body = { + login, + password, }; - return this.http.post<any>(`${this.API_URL}/users/login`, body); + return this.http.post<Response>(`${this.API_URL}/users/login`, body); ``` Never take `NgForm` in a service.
clement.freville2 marked this conversation as resolved
src/styles.scss Outdated
}
html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }

It is the same style as above...

It is the same style as above...
clement.freville2 marked this conversation as resolved
hugo.pradier2 added 1 commit 5 months ago
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is failing Details
c1a87b13d8
petits correctifs
hugo.pradier2 added 1 commit 5 months ago
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is failing Details
cd42d18848
.nx in gitignore
hugo.pradier2 added 1 commit 5 months ago
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is failing Details
7de3db7c66
remove nx
hugo.pradier2 requested review from clement.freville2 5 months ago
hugo.pradier2 added 1 commit 5 months ago
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is passing Details
2d5c4f126e
correctifs
hugo.pradier2 added 1 commit 5 months ago
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is passing Details
2aafd3e320
ajout logout
clement.freville2 added 1 commit 5 months ago
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/pr Build is failing Details
3067443127
Merge branch 'master' into form-login-register
clement.freville2 added 1 commit 5 months ago
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
e7501561aa
Fix tests
clement.freville2 approved these changes 5 months ago
clement.freville2 added 1 commit 5 months ago
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
825afb69ab
Remove duplicated lines
clement.freville2 merged commit 80c0d99bee into master 5 months ago
clement.freville2 deleted branch form-login-register 5 months ago

Reviewers

clement.freville2 approved these changes 5 months ago
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
The pull request has been merged as 80c0d99bee.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: sandkasten/sandkasten-web#14
Loading…
There is no content yet.