diff --git a/backend/controllers/authController.js b/backend/controllers/authController.js
index 0be461e..b1dbb87 100644
--- a/backend/controllers/authController.js
+++ b/backend/controllers/authController.js
@@ -27,7 +27,7 @@ export const register = async (req, res) => {
// Hash du mot de passe
const hashedPassword = await bcrypt.hash(password_hash, 10);
const result = await conn.query(
- 'INSERT INTO users (email, firstname, lastname, password_hash) VALUES (?, ?, ?, ?, ?)',
+ 'INSERT INTO users (email, firstname, lastname, password_hash) VALUES (?, ?, ?, ?)',
[email, firstname, lastname, hashedPassword]
);
res.status(201).json({
@@ -83,7 +83,7 @@ export const login = async (req, res) => {
'UPDATE users SET updated_at = CURRENT_TIMESTAMP WHERE id = ?',
[user.id]
);
- await setLogs(email + " s'est connecté !")
+
res.cookie('jwt', token, {
httpOnly: true,
secure: true,
diff --git a/src/app/_component/sidbar/sidbar.component.html b/src/app/_component/sidbar/sidbar.component.html
index 6661e5c..c432250 100644
--- a/src/app/_component/sidbar/sidbar.component.html
+++ b/src/app/_component/sidbar/sidbar.component.html
@@ -85,8 +85,8 @@
Profile
-
+
-
- Pas encore de compte? S'inscrire
+ Pas encore de compte ? S'inscrire
diff --git a/src/app/public/pages/login/login.component.ts b/src/app/public/pages/login/login.component.ts
index a82396a..9834619 100644
--- a/src/app/public/pages/login/login.component.ts
+++ b/src/app/public/pages/login/login.component.ts
@@ -1,14 +1,75 @@
-import { Component } from '@angular/core';
-import {RouterLink} from '@angular/router';
+import {Component, OnInit} from '@angular/core';
+import {ActivatedRoute, Router, RouterLink} from '@angular/router';
+import {Title} from '@angular/platform-browser';
+import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
+import {AuthService} from '../../../_services/auth.service';
+import {NgClass, NgIf} from '@angular/common';
@Component({
selector: 'app-login',
imports: [
- RouterLink
+ RouterLink,
+ NgIf,
+ ReactiveFormsModule,
+ NgClass
],
templateUrl: './login.component.html',
styleUrl: './login.component.css'
})
-export class LoginComponent {
+export class LoginComponent implements OnInit {
+ loginForm: FormGroup;
+ isSubmitting = false;
+ loginError = '';
+ registrationSuccess = false;
+ constructor(
+ private title: Title,
+ private fb: FormBuilder,
+ private authService: AuthService,
+ private router: Router,
+ private route: ActivatedRoute
+ ) {
+ this.loginForm = this.fb.group({
+ email: ['', [Validators.required, Validators.email]],
+ password: ['', [Validators.required]]
+ });
+ }
+
+ ngOnInit(): void {
+ this.title.setTitle('Connexion - YouVideo');
+ this.route.queryParams.subscribe(params => {
+ if (params['registered'] === 'success') {
+ this.registrationSuccess = true;
+ }
+ });
+ }
+
+ onSubmit(): void {
+ if (this.loginForm.invalid) {
+ Object.keys(this.loginForm.controls).forEach(key => {
+ const control = this.loginForm.get(key);
+ control?.markAsTouched();
+ });
+ return;
+ }
+
+ this.isSubmitting = true;
+ this.loginError = '';
+
+ const loginData = {
+ email: this.loginForm.value.email,
+ password: this.loginForm.value.password
+ };
+
+ this.authService.login(loginData).subscribe({
+ next: (response) => {
+ this.isSubmitting = false;
+ this.router.navigate(['/']);
+ },
+ error: (error) => {
+ this.isSubmitting = false;
+ this.loginError = error.error?.message || 'Identifiants incorrects. Veuillez réessayer.';
+ }
+ });
+ }
}
diff --git a/src/app/public/pages/not-found/not-found.component.ts b/src/app/public/pages/not-found/not-found.component.ts
index 8e7b578..dd624c7 100644
--- a/src/app/public/pages/not-found/not-found.component.ts
+++ b/src/app/public/pages/not-found/not-found.component.ts
@@ -1,4 +1,5 @@
-import { Component } from '@angular/core';
+import {Component, OnInit} from '@angular/core';
+import {Title} from '@angular/platform-browser';
@Component({
selector: 'app-not-found',
@@ -6,6 +7,13 @@ import { Component } from '@angular/core';
templateUrl: './not-found.component.html',
styleUrl: './not-found.component.css'
})
-export class NotFoundComponent {
+export class NotFoundComponent implements OnInit {
+
+ constructor(private title: Title) {
+ }
+
+ ngOnInit(): void {
+ this.title.setTitle('404 - YouVideo');
+ }
}
diff --git a/src/app/public/pages/register/register.component.html b/src/app/public/pages/register/register.component.html
index 9258500..b798bf4 100644
--- a/src/app/public/pages/register/register.component.html
+++ b/src/app/public/pages/register/register.component.html
@@ -5,39 +5,124 @@
Entrez vos informations pour vous inscrire
-