|
|
|
@ -42,6 +42,9 @@ export class LoginComponent {
|
|
|
|
|
|
|
|
|
|
errorMessage = '';
|
|
|
|
|
|
|
|
|
|
successLogin = '';
|
|
|
|
|
errorLogin = '';
|
|
|
|
|
|
|
|
|
|
constructor(private userService: UserService) {
|
|
|
|
|
merge(this.email.statusChanges, this.email.valueChanges)
|
|
|
|
|
.pipe(takeUntilDestroyed())
|
|
|
|
@ -58,7 +61,46 @@ export class LoginComponent {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// register() {
|
|
|
|
|
// console.log('registering user :', this.login.value);
|
|
|
|
|
|
|
|
|
|
// const form: any = {
|
|
|
|
|
// value: {
|
|
|
|
|
// login: this.login.value,
|
|
|
|
|
// password: this.password.value,
|
|
|
|
|
// },
|
|
|
|
|
// };
|
|
|
|
|
// this.userService.postUser(form).subscribe((response) => {
|
|
|
|
|
// console.log('response :', response);
|
|
|
|
|
// if ((response as any).success) {
|
|
|
|
|
// this.successRegister = 'Votre compte a été créé avec succès.';
|
|
|
|
|
// this.errorRegister = '';
|
|
|
|
|
// } else {
|
|
|
|
|
// this.errorRegister =
|
|
|
|
|
// "L'inscription a échoué : un compte avec ce login existe déjà.";
|
|
|
|
|
// this.successRegister = '';
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
loginAction() {
|
|
|
|
|
console.log('logining user :', this.login.value);
|
|
|
|
|
console.log('login user :', this.login.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 = '';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|