浏览代码

debug au chargement du site

DESKTOP-SMCIPAV\falko 4 月之前
父节点
当前提交
396b4984ed

文件差异内容过多而无法显示
+ 3 - 3
angular-client/dist/fatboar/browser/index.html


文件差异内容过多而无法显示
+ 1 - 0
angular-client/dist/fatboar/browser/main-es2015.6d495c44cb8c9af23fcf.js


文件差异内容过多而无法显示
+ 0 - 1
angular-client/dist/fatboar/browser/main-es2015.ea61f60306f0b9f06d1c.js


文件差异内容过多而无法显示
+ 1 - 1
angular-client/dist/fatboar/browser/main-es5.ea61f60306f0b9f06d1c.js


+ 1 - 1
angular-client/dist/fatboar/browser/robots.txt

@@ -18,4 +18,4 @@ Disallow: /admin
 # Disallow: /auth ← à commenter ou supprimer si accessible publiquement
 
 # Sitemap pour Google
-Sitemap: https://angular-preprod.foodgame.fr/sitemap.xml
+Sitemap: https://angular-dev.foodgame.fr/sitemap.xml

+ 8 - 8
angular-client/dist/fatboar/browser/sitemap.xml

@@ -2,52 +2,52 @@
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <!-- Accueil -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/</loc>
+    <loc>https://angular-dev.foodgame.fr/</loc>
     <changefreq>daily</changefreq>
     <priority>1.0</priority>
   </url>
 
   <!-- Inscription (OK pour l’indexation) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/register</loc>
+    <loc>https://angular-dev.foodgame.fr/register</loc>
     <changefreq>weekly</changefreq>
     <priority>0.8</priority>
   </url>
 
   <!-- Pages d'information légales (OK pour indexation) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/cgu</loc>
+    <loc>https://angular-dev.foodgame.fr/cgu</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
   <url>
-    <loc>https://angular-preprod.foodgame.fr/mention-legales</loc>
+    <loc>https://angular-dev.foodgame.fr/mention-legales</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
   <url>
-    <loc>https://angular-preprod.foodgame.fr/politique-de-confidentialite</loc>
+    <loc>https://angular-dev.foodgame.fr/politique-de-confidentialite</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
 
   <!-- Contact (OK) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/contact</loc>
+    <loc>https://angular-dev.foodgame.fr/contact</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
 
   <!-- Tirage (visible publiquement ?) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/tirage</loc>
+    <loc>https://angular-dev.foodgame.fr/tirage</loc>
     <changefreq>weekly</changefreq>
     <priority>0.6</priority>
   </url>
 
   <!-- Auth (si accessible publiquement) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/auth</loc>
+    <loc>https://angular-dev.foodgame.fr/auth</loc>
     <changefreq>weekly</changefreq>
     <priority>0.7</priority>
   </url>

文件差异内容过多而无法显示
+ 1 - 1
angular-client/dist/fatboar/server/main.js


+ 10 - 10
angular-client/src/app/app-routing.module.ts.rej

@@ -68,7 +68,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, concours, range rover, burgers, menus, réductions, restauration',
 +      ogTitle: 'Grand Jeu-Concours Fatboar',
 +      ogDescription: 'Tentez votre chance pour gagner un Range Rover et d’autres prix sur Fatboar.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/img/concours/range.png'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/img/concours/range.png'
 +    }
 +  },
 +  { 
@@ -80,7 +80,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, concours, range rover, burgers, menus, réductions, restauration',
 +      ogTitle: 'Grand Jeu-Concours Fatboar',
 +      ogDescription: 'Tentez votre chance pour gagner un Range Rover et d’autres prix sur Fatboar.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/img/concours/range.png'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/img/concours/range.png'
 +    }
 +  },
 +  { 
@@ -122,7 +122,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, inscription, concours, restauration',
 +      ogTitle: 'Inscription - Fatboar',
 +      ogDescription: 'Rejoignez Fatboar pour participer à nos concours exclusifs.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +    }
 +  },
 +  { 
@@ -134,7 +134,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, cgu, conditions générales, restauration',
 +      ogTitle: 'CGU - Fatboar',
 +      ogDescription: 'Conditions générales d’utilisation de Fatboar.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +    }
 +  },
 +  { 
@@ -146,7 +146,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, mentions légales, restauration',
 +      ogTitle: 'Mentions Légales - Fatboar',
 +      ogDescription: 'Mentions légales de Fatboar.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +    }
 +  },
 +  { 
@@ -158,7 +158,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, politique de confidentialité, données personnelles',
 +      ogTitle: 'Politique de Confidentialité - Fatboar',
 +      ogDescription: 'Politique de confidentialité de Fatboar.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +    }
 +  },
 +  { 
@@ -170,7 +170,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, contact, assistance, restauration',
 +      ogTitle: 'Contact - Fatboar',
 +      ogDescription: 'Contactez Fatboar pour toute question.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +    }
 +  },
 +  { 
@@ -182,7 +182,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +      keywords: 'fatboar, tirages, concours, restauration',
 +      ogTitle: 'Tirages - Fatboar',
 +      ogDescription: 'Découvrez les tirages en cours sur Fatboar.',
-+      ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++      ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +    }
 +  },
 +  { 
@@ -281,7 +281,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +  //     keywords: 'fatboar, tirage, concours, restauration',
 +  //     ogTitle: 'Tirage - Fatboar',
 +  //     ogDescription: 'Détails d’un tirage sur Fatboar.',
-+  //     ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++  //     ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +  //   }
 +  // },
 +  // Activer si /restaurants/:id existe
@@ -294,7 +294,7 @@ diff a/angular-client/src/app/app-routing.module.ts b/angular-client/src/app/app
 +  //     keywords: 'fatboar, restaurant, restauration',
 +  //     ogTitle: 'Restaurant - Fatboar',
 +  //     ogDescription: 'Détails d’un restaurant Fatboar.',
-+  //     ogImage: 'https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg'
++  //     ogImage: 'https://angular-dev.foodgame.fr/assets/fatboar-og.jpg'
 +  //   }
 +  // }
  ];

+ 1 - 1
angular-client/src/app/app.component.ts

@@ -47,7 +47,7 @@ export class AppComponent implements OnInit {
       }
 
       // 🔹 Ajoute ou met à jour la balise <link rel="canonical">
-      this.seoService.setCanonical(`https://angular-preprod.foodgame.fr${this.router.url}`);
+      this.seoService.setCanonical(`https://angular-dev.foodgame.fr${this.router.url}`);
     });
   }
 }

+ 6 - 6
angular-client/src/app/components/home/home.component.ts

@@ -33,7 +33,7 @@ export class HomeComponent implements OnInit {
         addressCountry: 'FR'
       }
     },
-    image: 'https://angular-preprod.foodgame.fr/assets/img/concours/range.png',
+    image: 'https://angular-dev.foodgame.fr/assets/img/concours/range.png',
     offers: {
       '@type': 'Offer',
       name: 'Participation au concours',
@@ -41,12 +41,12 @@ export class HomeComponent implements OnInit {
       priceCurrency: 'EUR',
       availability: 'https://schema.org/InStock',
       validFrom: '2020-07-16',
-      url: 'https://angular-preprod.foodgame.fr'
+      url: 'https://angular-dev.foodgame.fr'
     },
     organizer: {
       '@type': 'Organization',
       name: 'Fatboar',
-      url: 'https://angular-preprod.foodgame.fr'
+      url: 'https://angular-dev.foodgame.fr'
     }
   };
 
@@ -129,7 +129,7 @@ export class HomeComponent implements OnInit {
 //         addressCountry: 'FR'
 //       }
 //     },
-//     image: 'https://angular-preprod.foodgame.fr/assets/img/concours/range.png',
+//     image: 'https://angular-dev.foodgame.fr/assets/img/concours/range.png',
 //     offers: {
 //       '@type': 'Offer',
 //       name: 'Participation au concours',
@@ -137,12 +137,12 @@ export class HomeComponent implements OnInit {
 //       priceCurrency: 'EUR',
 //       availability: 'https://schema.org/InStock',
 //       validFrom: '2020-07-16',
-//       url: 'https://angular-preprod.foodgame.fr'
+//       url: 'https://angular-dev.foodgame.fr'
 //     },
 //     organizer: {
 //       '@type': 'Organization',
 //       name: 'Fatboar',
-//       url: 'https://angular-preprod.foodgame.fr'
+//       url: 'https://angular-dev.foodgame.fr'
 //     }
 //   };
 

+ 1 - 0
angular-client/src/app/components/shared/contact/map/map.component.scss

@@ -15,3 +15,4 @@
     height: 300px;
   }
 }
+ 

+ 55 - 73
angular-client/src/app/components/shared/navbar/navbar.component.html

@@ -1,4 +1,4 @@
-<div>
+<div *ngIf="isBrowser">
 
   <mat-toolbar color="primary" class="fatboar-navbar">
     <div fxShow="true" fxHide.gt-sm="true">
@@ -6,94 +6,76 @@
         <mat-icon>menu</mat-icon>
       </button>
     </div>
-    
-    <a  routerLink="/" class="">
-    <span><img  src="assets/img/logo-fatboar.png"  width="50" height="50" class="logo-fatboar"  alt="fatboar"></span>  
-      
-    </a> 
+
+    <a routerLink="/">
+      <span>
+        <img src="assets/img/logo-fatboar.png" width="50" height="50" class="logo-fatboar" alt="fatboar">
+      </span>
+    </a>
+
     <span class="example-spacer"></span>
+
     <div fxShow="true" fxHide.lt-md="true">
-      <a class="navbtn" mat-button routerLink="/login" *ngIf="!isLogged"> Connexion</a>
+      <a class="navbtn" mat-button routerLink="/login" *ngIf="!isLogged">Connexion</a>
       <a class="navbtn" mat-button routerLink="/register" *ngIf="!isLogged">Inscription</a>
       <a class="navbtn" mat-button routerLink="/auth" *ngIf="isLogged && !isAdmin">Gain</a>
-      <a class="navbtn" mat-button routerLink="/tirage" [hidden]="!isAdmin">Tirage</a>
-      <a class="navbtn" mat-button routerLink="/profil" *ngIf="isLogged"><mat-icon>person</mat-icon>Mon profil</a>
-      <a class="navbtn" mat-button routerLink="/users" [hidden]="!isAdmin">Clients</a>
-      <a class="navbtn" mat-button routerLink="/statistique" [hidden]="!isAdmin">Statistique</a>
-      <a class="navbtn" mat-button routerLink="/emailing" [hidden]="!isAdmin">Emailing</a>
-      <a class="navbtn" mat-button routerLink="/assistance" [hidden]="!isAdmin">Assistance</a>
-      <!-- <a class="navbtn" mat-button routerLink="/users" [hidden]="!isAdmin">Employés</a> -->
-      <a class="navbtn" mat-button routerLink="/contact" *ngIf="!isLogged && !isAdmin" >Contact</a>
+      <a class="navbtn" mat-button routerLink="/tirage" *ngIf="isAdmin">Tirage</a>
+      <a class="navbtn" mat-button routerLink="/profil" *ngIf="isLogged">
+        <mat-icon>person</mat-icon>Mon profil
+      </a>
+      <a class="navbtn" mat-button routerLink="/users" *ngIf="isAdmin">Clients</a>
+      <a class="navbtn" mat-button routerLink="/statistique" *ngIf="isAdmin">Statistique</a>
+      <a class="navbtn" mat-button routerLink="/emailing" *ngIf="isAdmin">Emailing</a>
+      <a class="navbtn" mat-button routerLink="/assistance" *ngIf="isAdmin">Assistance</a>
+      <a class="navbtn" mat-button routerLink="/contact" *ngIf="!isLogged && !isAdmin">Contact</a>
       <a class="navbtn" mat-icon-button color="basic" aria-label="" (click)="logOut()" *ngIf="isLogged">
         <mat-icon>power_settings_new</mat-icon>
       </a>
     </div>
   </mat-toolbar>
 
-
-
-
-
-
-
   <mat-sidenav-container fxFlexFill class="fatboar-sidenav-containe">
-
-     <!-- le menu -->
-    <mat-sidenav color="primary" #sidenav fxLayout="column" mode="over" opened="false" fxHide.gt-sm="true">
+    <mat-sidenav #sidenav fxLayout="column" mode="over" opened="false" fxHide.gt-sm="true">
       <div fxLayout="column" class="msidenav">
-        <!-- <a mat-button routerLink="/about-us">About us</a>
-        <a mat-button routerLink="/prices">Prices</a>
-        <a mat-button routerLink="/start-page">Start page</a>
-        <a mat-button routerLink="/offer">  <mat-icon>home</mat-icon>Offer</a>
-        <a mat-button routerLink="/contact">Contact</a> -->
         <mat-nav-list>
-        <a mat-list-item routerLink="/" *ngIf="!isLogged">
-          <mat-icon mat-list-icon>home</mat-icon>
-          <span mat-line>Menu</span>
-        </a>
-        <a mat-list-item routerLink="/login" *ngIf="!isLogged">
-          <mat-icon mat-list-icon>account_circle</mat-icon>
-          <span mat-line>Connexion</span>
-        </a>
-        <a mat-list-item routerLink="/register" *ngIf="!isLogged">
-          <mat-icon mat-list-icon>article</mat-icon>
-          <span mat-line>Inscription</span>
-        </a>
-        <a mat-list-item routerLink="/user" *ngIf="isLogged">
-          <mat-icon mat-list-icon>account_circle</mat-icon>
-          <span mat-line>users</span>
-        </a>
-        <a mat-list-item routerLink="/contact">
-          <mat-icon mat-list-icon>forward_to_inbox</mat-icon>
-          <span mat-line>Contact</span>
-        </a>
-        <a mat-list-item (click)="logOut()" *ngIf="isLogged">
-          <mat-icon mat-list-icon>power_settings_new</mat-icon>
-          <span mat-line>Déconnecter</span>
-        </a>
-        <a mat-list-item (click)="sidenav.toggle()">
-          <mat-icon mat-list-icon>clear</mat-icon>
-          <span mat-line>Fermer</span>
-        </a>
-      </mat-nav-list>
-        <!-- <a mat-button (click)="sidenav.toggle()" >Close</a>
-        <a class="navbtn" mat-button (click)="sidenav.toggle()" color="basic" aria-label="">
-          <mat-icon>clear</mat-icon>
-        </a> -->
+          <a mat-list-item routerLink="/" *ngIf="!isLogged">
+            <mat-icon mat-list-icon>home</mat-icon>
+            <span mat-line>Menu</span>
+          </a>
+          <a mat-list-item routerLink="/login" *ngIf="!isLogged">
+            <mat-icon mat-list-icon>account_circle</mat-icon>
+            <span mat-line>Connexion</span>
+          </a>
+          <a mat-list-item routerLink="/register" *ngIf="!isLogged">
+            <mat-icon mat-list-icon>article</mat-icon>
+            <span mat-line>Inscription</span>
+          </a>
+          <a mat-list-item routerLink="/user" *ngIf="isLogged">
+            <mat-icon mat-list-icon>account_circle</mat-icon>
+            <span mat-line>users</span>
+          </a>
+          <a mat-list-item routerLink="/contact">
+            <mat-icon mat-list-icon>forward_to_inbox</mat-icon>
+            <span mat-line>Contact</span>
+          </a>
+          <a mat-list-item (click)="logOut()" *ngIf="isLogged">
+            <mat-icon mat-list-icon>power_settings_new</mat-icon>
+            <span mat-line>Déconnecter</span>
+          </a>
+          <a mat-list-item (click)="sidenav.toggle()">
+            <mat-icon mat-list-icon>clear</mat-icon>
+            <span mat-line>Fermer</span>
+          </a>
+        </mat-nav-list>
       </div>
     </mat-sidenav>
 
     <mat-sidenav-content fxFlexFill class="fatboar-sidenav-content">
-      
-     <router-outlet></router-outlet>
-     <div class="footer">
-      <app-footer></app-footer>
-     </div>
-
-      
+      <router-outlet></router-outlet>
+      <div class="footer">
+        <app-footer></app-footer>
+      </div>
     </mat-sidenav-content>
-  
   </mat-sidenav-container>
-  
-  
-</div>
+
+</div>

+ 28 - 21
angular-client/src/app/components/shared/navbar/navbar.component.ts

@@ -1,36 +1,43 @@
 import { AuthService } from 'src/app/services/auth.service';
-import { Component, OnInit, Output } from '@angular/core';
+import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
+import { isPlatformBrowser } from '@angular/common';
 import { User } from '../../../models/userResponse';
 
-
 @Component({
   selector: 'app-navbar',
   templateUrl: './navbar.component.html',
   styleUrls: ['./navbar.component.scss']
 })
 export class NavbarComponent implements OnInit {
-  isLogged: User;
+  isLogged: User | null = null;
   isAdmin: boolean = false;
-  constructor(private authService : AuthService) { 
-    console.log('Variable', this.isAdmin)
-    this.authService.user_info.subscribe((x) =>{
-      this.isLogged = x;
-      this.isLogged.role ==='admin' ? this.isAdmin = true : this.isAdmin = false;
-      console.log('Variable dedans', this.isAdmin);
-
-    });
-
+  isLoggedIn: boolean = false;
+  isBrowser: boolean = false;
+
+  constructor(
+    private authService: AuthService,
+    @Inject(PLATFORM_ID) private platformId: Object
+  ) {
+    this.isBrowser = isPlatformBrowser(this.platformId);
+
+    if (this.isBrowser) {
+      this.authService.user_info.subscribe((user) => {
+        if (user) {
+          this.isLogged = user;
+          this.isLoggedIn = true;
+          this.isAdmin = user.role === 'admin';
+        } else {
+          this.isLogged = null;
+          this.isLoggedIn = false;
+          this.isAdmin = false;
+        }
+      });
+    }
   }
 
-  ngOnInit(): void {
-    //console.log(this.isLogged)
+  ngOnInit(): void {}
 
+  logOut() {
+    this.authService.logout();
   }
-  
-
-  logOut(){
-    this.authService.logout()
-  }
-
 }
-

+ 27 - 12
angular-client/src/app/guards/auth.guard.ts

@@ -1,7 +1,6 @@
 import { Injectable } from '@angular/core';
-import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
-import { Observable } from 'rxjs';
-import { AuthService } from 'src/app/services/auth.service'
+import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
+import { AuthService } from 'src/app/services/auth.service';
 
 @Injectable({
   providedIn: 'root'
@@ -9,22 +8,38 @@ import { AuthService } from 'src/app/services/auth.service'
 export class AuthGuard implements CanActivate {
   constructor(private router: Router, private authService: AuthService) {}
   
-  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
+  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
     const currentUser = this.authService.userValue;
+    
+    // Debug logging to understand what's happening
+    console.log('AuthGuard Debug:', {
+      currentUser: currentUser,
+      userRole: currentUser?.role,
+      routeRoles: route.data?.roles,
+      hasToken: this.authService.tokenValue !== null
+    });
+    
     if (currentUser) {
-        // check if route is restricted by role
-        if (route.data.roles && route.data.roles.indexOf(currentUser.role) === -1) {
-            // role not authorised so redirect to home page
-            this.router.navigate(['/']);
-            return false;
+      // check if route is restricted by role
+      if (route.data?.roles && route.data.roles.length > 0) {
+        // Check if user has a role and if it's in the allowed roles
+        if (!currentUser.role || route.data.roles.indexOf(currentUser.role) === -1) {
+          // role not authorized or user has no role, redirect to home page
+          console.warn('Access denied: User role not authorized for this route', {
+            userRole: currentUser.role,
+            requiredRoles: route.data.roles
+          });
+          this.router.navigate(['/']);
+          return false;
         }
+      }
 
-        // authorised so return true
-        return true;
+      // authorized so return true
+      return true;
     }
 
     // not logged in so redirect to login page with the return url
     this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } });
     return false;
-}
+  }
 }

+ 206 - 39
angular-client/src/app/services/auth.service.ts

@@ -10,40 +10,19 @@ import { AlertMessageComponent } from 'src/app/components/shared/alert-message/a
 import { map, tap } from 'rxjs/operators';
 import * as jwt_decode from 'jwt-decode';
 import { isPlatformBrowser } from '@angular/common';
-import { StorageService } from 'src/app/services/storage.service';
+import { StorageService } from 'src/app/services/storage.service'; // Assurez-vous de créer ce service
 
 @Injectable({
   providedIn: 'root'
 })
 export class AuthService {
   private apiUrl = environment.apiUrl;
-
-  // Définir un utilisateur par défaut pour éviter les null
-  private defaultUser: User = {
-    _id: '',
-    firstname: '',
-    lastname: '',
-    email: '',
-    role: '',
-    googleId: '',
-    birthday: new Date(0),
-    phonenumber: 0,
-    adress: '',
-    isActive: false,
-    isGain: false,
-    register_date: new Date(0),
-    gains: []
-  };
-
   private currentUserSubject: BehaviorSubject<User> = new BehaviorSubject<User>(null);
   public currentUser: Observable<User> = this.currentUserSubject.asObservable();
-
   private tokenSubject: BehaviorSubject<Token>;
   public token: Observable<Token>;
-
   private user_infoSubject: BehaviorSubject<User>;
   public user_info: Observable<User>;
-
   private messageSource = new BehaviorSubject('default message');
   currentMessage = this.messageSource.asObservable();
 
@@ -54,14 +33,10 @@ export class AuthService {
     private storageService: StorageService,
     @Inject(PLATFORM_ID) private platformId: Object
   ) {
-    this.tokenSubject = new BehaviorSubject<Token>(
-      JSON.parse(this.storageService.getItem('token'))
-    );
+    this.tokenSubject = new BehaviorSubject<Token>(JSON.parse(this.storageService.getItem('token')));
     this.token = this.tokenSubject.asObservable();
-
-    // Utiliser defaultUser si rien en storage
-    const storedUser = JSON.parse(this.storageService.getItem('user'));
-    this.user_infoSubject = new BehaviorSubject<User>(storedUser || this.defaultUser);
+    const storedUser = this.storageService.getItem('user');
+    this.user_infoSubject = new BehaviorSubject<User>(JSON.parse(this.storageService.getItem('user')));
     this.user_info = this.user_infoSubject.asObservable();
   }
 
@@ -78,7 +53,7 @@ export class AuthService {
   }
 
   signIn(credentials): Observable<Token> {
-    return this.http.post<Token>(`https://api-preprod.foodgame.fr/api/auth/login`, credentials)
+    return this.http.post<Token>(`https://api-dev.foodgame.fr/api/auth/login`, credentials)
       .pipe(map(token => {
         this.storageService.setItem('token', JSON.stringify(token));
         this.tokenSubject.next(token);
@@ -89,15 +64,15 @@ export class AuthService {
   signInWithGoogle(): Observable<User> {
     return this.http.get<User>(`${this.apiUrl}/api/auth/google`).pipe(
       map(user => {
+        console.log('je suis present', user);
         this.storageService.setItem('user', JSON.stringify(user));
-        this.user_infoSubject.next(user);
         return user;
       })
     );
   }
 
   signInAdmin(credentials): Observable<Token> {
-    return this.http.post<Token>(`https://api-preprod.foodgame.fr/api/auth/admin`, credentials)
+    return this.http.post<Token>(`https://api-dev.foodgame.fr/api/auth/admin`, credentials)
       .pipe(map(token => {
         this.storageService.setItem('token', JSON.stringify(token));
         this.tokenSubject.next(token);
@@ -106,7 +81,7 @@ export class AuthService {
   }
 
   signUP(data): Observable<Token> {
-    return this.http.post<Token>(`https://api-preprod.foodgame.fr/api/auth/signup`, data)
+    return this.http.post<Token>(`https://api-dev.foodgame.fr/api/auth/signup`, data)
       .pipe(map(token => {
         this.storageService.setItem('token', JSON.stringify(token));
         this.tokenSubject.next(token);
@@ -115,11 +90,11 @@ export class AuthService {
   }
 
   lostPassword(email): Observable<any> {
-    return this.http.put<any>(`https://api-preprod.foodgame.fr/api/auth/forgot-password`, email);
+    return this.http.put<any>(`https://api-dev.foodgame.fr/api/auth/forgot-password`, email);
   }
 
   resetPassword(data): Observable<any> {
-    return this.http.put<any>(`https://api-preprod.foodgame.fr/api/auth/reset-password`, data);
+    return this.http.put<any>(`https://api-dev.foodgame.fr/api/auth/reset-password`, data);
   }
 
   public isLoggedIn() {
@@ -138,7 +113,7 @@ export class AuthService {
     this.storageService.removeItem('token');
     this.tokenSubject.next(null);
     this.storageService.removeItem('user');
-    this.user_infoSubject.next(this.defaultUser); // Mettre un user vide
+    this.user_infoSubject.next(null);
     this.router.navigate(['/login']);
     if (isPlatformBrowser(this.platformId)) {
       setTimeout(() => {
@@ -148,12 +123,12 @@ export class AuthService {
   }
 
   getUserInfo(): Observable<User> {
-    let decodedToken: payloadToken = jwt_decode(this.tokenSubject.value.token);
-    return this.http.get<User>(`https://api-preprod.foodgame.fr/api/users/${decodedToken.userId}`)
+    let decodedToken: payloadToken = jwt_decode(this.tokenSubject.value.token); 
+    return this.http.get<User>(`https://api-dev.foodgame.fr/api/users/${decodedToken.userId}`)
       .pipe(map(user => {
         this.storageService.setItem('user', JSON.stringify(user));
         this.user_infoSubject.next(user);
-        return user;
+        return user; 
       }));
   }
 
@@ -165,3 +140,195 @@ export class AuthService {
     });
   }
 }
+
+
+// import { environment } from 'src/environments/environment';
+// import { User } from './../models/userResponse';
+// import { Token, payloadToken } from './../models/token';
+// import { Injectable } from '@angular/core';
+// import { HttpClient, HttpHeaders } from '@angular/common/http';
+// import { BehaviorSubject, Observable, throwError } from 'rxjs';
+// import { Router } from '@angular/router';
+// import { MatSnackBar } from '@angular/material/snack-bar';
+// import { AlertMessageComponent } from 'src/app/components/shared/alert-message/alert-message.component'
+// import { catchError, map, tap } from 'rxjs/operators';
+// import * as jwt_decode from 'jwt-decode';
+
+
+
+// @Injectable({
+//   providedIn: 'root'
+// })
+// export class AuthService {
+
+//   //url api
+//   private apiUrl = environment.apiUrl
+
+//   private currentUserSubject: BehaviorSubject<User> = new BehaviorSubject<User>(null);
+//   public currentUser: Observable<User> = this.currentUserSubject.asObservable();
+
+  
+
+
+//   private tokenSubject: BehaviorSubject<Token>;
+//   public token: Observable<Token>;
+
+//   private user_infoSubject: BehaviorSubject<User>;
+//   public user_info: Observable<User>;
+
+//   private messageSource = new BehaviorSubject('default message');
+//   currentMessage = this.messageSource.asObservable();
+
+//   constructor(private http: HttpClient, public router: Router, public snackBar: MatSnackBar) {
+
+//     this.tokenSubject = new BehaviorSubject<Token>(JSON.parse(localStorage.getItem('token')));
+//     this.token = this.tokenSubject.asObservable();
+
+//     this.user_infoSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('user')));
+//     this.user_info = this.user_infoSubject.asObservable();
+    
+//   }
+
+//   changeMessage(message: string) {
+//     this.messageSource.next(message)
+//   }
+
+//   //get token
+//   public get tokenValue(): Token {
+//     return this.tokenSubject.value;
+//   }
+
+//   //get user Info
+//   public get userValue(): User {
+//     return this.user_infoSubject.value;
+//   }
+
+//   // login get  token on login 
+//   signIn(credentials): Observable<Token> {
+//      //debugger;
+//     console.log("url ========",this.apiUrl);
+
+//     return this.http.post<Token>(`${this.apiUrl}/api/auth/login`, credentials)
+//       .pipe(map(token => {
+//         // store jwt token in local storage 
+//         localStorage.setItem('token', JSON.stringify(token));
+//         this.tokenSubject.next(token);
+//         return token;
+//       }));
+//   }
+
+
+//   // Méthode pour s'authentifier avec Google
+//   signInWithGoogle(): Observable<User> {
+//     return this.http.get<User>(`${this.apiUrl}/api/auth/google`).pipe(
+//       map(user => {
+//         console.log('je suis present', user )
+//         localStorage.setItem('user', JSON.stringify(user));
+//         return user;
+//       })
+//     );
+//   }
+  
+//   // signInWithGoogle(): Observable<string> {
+//   //   return this.http.get<any>(`${this.apiUrl}/api/auth/google/callback`).pipe(
+//   //     map(response => response.token),
+//   //     catchError(error => {
+//   //       console.log(error);
+//   //       // Gérer l'erreur
+//   //       throw error;
+//   //     })
+//   //   );
+//   // }
+//     // login get  token on login admin
+//     signInAdmin(credentials): Observable<Token> {
+//        //debugger;
+//       console.log("url ========",this.apiUrl);
+  
+//       return this.http.post<Token>(`${this.apiUrl}/api/auth/admin`, credentials)
+//         .pipe(map(token => {
+//           // store jwt token in local storage 
+//           localStorage.setItem('token', JSON.stringify(token));
+//           this.tokenSubject.next(token);
+//           return token;
+//         }));
+//     }
+
+
+
+//   // iscription get  token on login 
+//   signUP(data): Observable<Token> {
+
+//     return this.http.post<Token>(`${this.apiUrl}/api/auth/signup`, data)
+//       .pipe(map(token => {
+//         // store jwt token in local storage 
+//         localStorage.setItem('token', JSON.stringify(token));
+//         this.tokenSubject.next(token);
+//         return token;
+//       }));
+//   }
+
+
+
+// // mot de passe oublie 
+// lostPassword(email): Observable<any> {
+//   return this.http.put<any>(`${this.apiUrl}/api/auth/forgot-password`, email)
+// }
+
+
+// // réinitialiser mot de passe  
+// resetPassword(data): Observable<any> {
+//   return this.http.put<any>(`${this.apiUrl}/api/auth/reset-password`, data)
+// }
+
+//   // isLoggedIn
+//   public isLoggedIn() {
+//     return localStorage.getItem('token') !== null;
+//   }
+
+//   getCurrentUser(): Observable<User> {
+//     return this.http.get<User>('/api/auth/user').pipe(
+//       tap((user) => {
+//         this.currentUserSubject.next(user);
+//       })
+//     );
+//   }
+
+//   //logout
+//   public logout() {
+//     // remove token from local storage 
+//     localStorage.removeItem('token');
+//     this.tokenSubject.next(null);
+//     // remove user from local storage 
+//     localStorage.removeItem('user');
+//     this.user_infoSubject.next(null);
+//     this.router.navigate(['/login']);
+//     setTimeout(() => {
+//       document.location.reload()
+//     },1000)
+//   }
+
+//    // get info user 
+//    getUserInfo(): Observable<User> {
+    
+//     let decodedToken : payloadToken = jwt_decode(this.tokenSubject.value.token); 
+//     return this.http.get<User>(`${this.apiUrl}/api/users/${decodedToken.userId}`)
+//       .pipe(map(user => {
+//         // store user info in local storage 
+//         localStorage.setItem('user', JSON.stringify(user));
+//         this.user_infoSubject.next(user);
+//         return user; 
+//       }));
+    
+//   }
+  
+
+//   openSnackBar(message: string) {
+//     this.snackBar.openFromComponent(AlertMessageComponent, {
+//       data: message,
+//       panelClass: ['blue-snackbar'],
+//       duration: 10000
+//     });
+//   }
+
+
+// }

+ 1 - 1
angular-client/src/app/services/email.service.ts

@@ -16,7 +16,7 @@ export class EmailService {
 
 // send email 
 sendEmail(data : Email, email: string, isgain: string, isactiive: string): Observable<Email> {
-  return this.http.post<Email>(`https://api-preprod.foodgame.fr/api/emails/send?email=${email}&isgain=${isgain}&isactive=${isactiive}`,data);
+  return this.http.post<Email>(`https://api-dev.foodgame.fr/api/emails/send?email=${email}&isgain=${isgain}&isactive=${isactiive}`,data);
 }
 
 

+ 1 - 1
angular-client/src/app/services/restaurants.service.ts

@@ -16,7 +16,7 @@ export class RestaurantsService {
 
   // get users
 getRestaurants(): Observable<Restaurant[]> {
-  return this.http.get<Restaurant[]>(`https://api-preprod.foodgame.fr/api/restaurants`);
+  return this.http.get<Restaurant[]>(`https://api-dev.foodgame.fr/api/restaurants`);
 }
 
 

+ 2 - 2
angular-client/src/index.html

@@ -25,10 +25,10 @@
   <meta name="twitter:card" content="summary_large_image">
   <meta name="twitter:title" content="Fatboar - Jeu-Concours">
   <meta name="twitter:description" content="Tentez votre chance pour gagner un Range Rover et d’autres prix avec Fatboar.">
-  <meta name="twitter:image" content="https://angular-preprod.foodgame.fr/assets/fatboar-og.jpg">
+  <meta name="twitter:image" content="https://angular-dev.foodgame.fr/assets/fatboar-og.jpg">
 
   <!-- Canonical & favicon -->
-  <link rel="canonical" href="https://angular-preprod.foodgame.fr">
+  <link rel="canonical" href="https://angular-dev.foodgame.fr">
   <link rel="icon" type="image/x-icon" href="favicon.ico">
 
   <!-- Fonts & Icons -->

+ 1 - 1
angular-client/src/robots.txt

@@ -18,4 +18,4 @@ Disallow: /admin
 # Disallow: /auth ← à commenter ou supprimer si accessible publiquement
 
 # Sitemap pour Google
-Sitemap: https://angular-preprod.foodgame.fr/sitemap.xml
+Sitemap: https://angular-dev.foodgame.fr/sitemap.xml

+ 8 - 8
angular-client/src/sitemap.xml

@@ -2,52 +2,52 @@
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <!-- Accueil -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/</loc>
+    <loc>https://angular-dev.foodgame.fr/</loc>
     <changefreq>daily</changefreq>
     <priority>1.0</priority>
   </url>
 
   <!-- Inscription (OK pour l’indexation) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/register</loc>
+    <loc>https://angular-dev.foodgame.fr/register</loc>
     <changefreq>weekly</changefreq>
     <priority>0.8</priority>
   </url>
 
   <!-- Pages d'information légales (OK pour indexation) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/cgu</loc>
+    <loc>https://angular-dev.foodgame.fr/cgu</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
   <url>
-    <loc>https://angular-preprod.foodgame.fr/mention-legales</loc>
+    <loc>https://angular-dev.foodgame.fr/mention-legales</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
   <url>
-    <loc>https://angular-preprod.foodgame.fr/politique-de-confidentialite</loc>
+    <loc>https://angular-dev.foodgame.fr/politique-de-confidentialite</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
 
   <!-- Contact (OK) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/contact</loc>
+    <loc>https://angular-dev.foodgame.fr/contact</loc>
     <changefreq>monthly</changefreq>
     <priority>0.6</priority>
   </url>
 
   <!-- Tirage (visible publiquement ?) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/tirage</loc>
+    <loc>https://angular-dev.foodgame.fr/tirage</loc>
     <changefreq>weekly</changefreq>
     <priority>0.6</priority>
   </url>
 
   <!-- Auth (si accessible publiquement) -->
   <url>
-    <loc>https://angular-preprod.foodgame.fr/auth</loc>
+    <loc>https://angular-dev.foodgame.fr/auth</loc>
     <changefreq>weekly</changefreq>
     <priority>0.7</priority>
   </url>