added creation of account but bad request (400)
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
<div class="flex-1 border-b border-gray-400"></div>
|
<div class="flex-1 border-b border-gray-400"></div>
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
} @else {
|
||||||
<app-sign-on-form></app-sign-on-form>
|
<app-sign-on-form #userForm></app-sign-on-form>
|
||||||
}
|
}
|
||||||
|
|
||||||
<ion-button class="w-10/12 mt-0" color="secondary" (click)="createAccount()">
|
<ion-button class="w-10/12 mt-0" color="secondary" (click)="createAccount()">
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import {Component, inject, signal, viewChild} from '@angular/core';
|
|||||||
import {IonicModule} from "@ionic/angular";
|
import {IonicModule} from "@ionic/angular";
|
||||||
import {SignInFormComponent} from "../../components/sign-in-form/sign-in-form.component";
|
import {SignInFormComponent} from "../../components/sign-in-form/sign-in-form.component";
|
||||||
import {SignOnFormComponent} from "../../components/sign-on-form/sign-on-form.component";
|
import {SignOnFormComponent} from "../../components/sign-on-form/sign-on-form.component";
|
||||||
import {firstValueFrom} from "rxjs";
|
|
||||||
import {AuthManageService} from "../../services/auth-manage";
|
import {AuthManageService} from "../../services/auth-manage";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {UsersService} from "../../services/api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
@@ -18,13 +19,16 @@ import {AuthManageService} from "../../services/auth-manage";
|
|||||||
export class LoginComponent {
|
export class LoginComponent {
|
||||||
authState = signal<boolean>(true)
|
authState = signal<boolean>(true)
|
||||||
login = viewChild<SignInFormComponent>('loginForm');
|
login = viewChild<SignInFormComponent>('loginForm');
|
||||||
|
user = viewChild<SignOnFormComponent>('userForm');
|
||||||
|
|
||||||
private authManageService = inject(AuthManageService);
|
private authManageService = inject(AuthManageService);
|
||||||
|
private usersService = inject(UsersService);
|
||||||
|
|
||||||
createAccount() {
|
async createAccount() {
|
||||||
if (this.authState()) {
|
if (this.authState()) {
|
||||||
this.authState.set(false);
|
this.authState.set(false);
|
||||||
} else if (this.authState() == false) {
|
} else if (this.authState() == false) {
|
||||||
|
await this.addUser();
|
||||||
this.authState.set(true);
|
this.authState.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,4 +38,18 @@ export class LoginComponent {
|
|||||||
console.log(user);
|
console.log(user);
|
||||||
this.authManageService.connectUser(user.username, user.password);
|
this.authManageService.connectUser(user.username, user.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async addUser() {
|
||||||
|
if (this.user().userForm.invalid) {
|
||||||
|
console.log('Erreur d\'écriture dans le formulaire');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const users = this.user().userForm.getRawValue();
|
||||||
|
await firstValueFrom(this.usersService.createUserEndpoint(users))
|
||||||
|
console.log('Utilisateur crée : ' + users);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* BeReadyBackend
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the dto used to send an error response to the client
|
||||||
|
*/
|
||||||
|
export interface ErrorResponse {
|
||||||
|
/**
|
||||||
|
* the http status code sent to the client. default is 400.
|
||||||
|
*/
|
||||||
|
statusCode?: number;
|
||||||
|
/**
|
||||||
|
* the message for the error response
|
||||||
|
*/
|
||||||
|
message?: string;
|
||||||
|
/**
|
||||||
|
* the collection of errors for the current context
|
||||||
|
*/
|
||||||
|
errors?: { [key: string]: Array<string>; };
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user