update des cookies pour le déploiement sur le domaine
This commit is contained in:
		
							parent
							
								
									789bbbf81d
								
							
						
					
					
						commit
						50179801b1
					
				| @ -64,7 +64,9 @@ | |||||||
|         "serve": { |         "serve": { | ||||||
|           "options": { |           "options": { | ||||||
|             "host": "0.0.0.0", |             "host": "0.0.0.0", | ||||||
|             "allowedHosts": ["abonentendeur.guams.fr"] |             "allowedHosts": [ | ||||||
|  |               "abonentendeur.guams.fr" | ||||||
|  |             ] | ||||||
|           }, |           }, | ||||||
|           "builder": "@angular-devkit/build-angular:dev-server", |           "builder": "@angular-devkit/build-angular:dev-server", | ||||||
|           "configurations": { |           "configurations": { | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| { | { | ||||||
|  |   "domain": "localhost", | ||||||
|   "serverAddress": "localhost", |   "serverAddress": "localhost", | ||||||
|   "apiURL": "http://localhost:8080/api", |   "apiURL": "http://localhost:8080/api", | ||||||
|   "tokenTTL": 36000000 |   "tokenTTL": 36000000 | ||||||
|  | |||||||
| @ -6,6 +6,10 @@ import * as config from '../../configuration.json' | |||||||
| }) | }) | ||||||
| export class ConfigurationService { | export class ConfigurationService { | ||||||
| 
 | 
 | ||||||
|  |   getDomain(): string { | ||||||
|  |     return config.domain; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   getApiUrl(): string { |   getApiUrl(): string { | ||||||
|     return config.apiURL |     return config.apiURL | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -45,8 +45,9 @@ export class LoginComponent implements OnDestroy { | |||||||
|       ( |       ( | ||||||
|         this.authorService.login(this.name, this.password).pipe( |         this.authorService.login(this.name, this.password).pipe( | ||||||
|           switchMap((tokenObj: any) => { |           switchMap((tokenObj: any) => { | ||||||
|             this.cookieService.delete('token', '/', this.configurationService.getServerAddress()) |             this.cookieService.delete('token', '/', this.configurationService.getDomain()) | ||||||
|             this.cookieService.set("token", tokenObj.token, { |             this.cookieService.set("token", tokenObj.token, { | ||||||
|  |               domain: this.configurationService.getDomain(), | ||||||
|               secure: true, |               secure: true, | ||||||
|               path: '/' |               path: '/' | ||||||
|             }); |             }); | ||||||
| @ -54,11 +55,13 @@ export class LoginComponent implements OnDestroy { | |||||||
|           })) |           })) | ||||||
|           .subscribe({ |           .subscribe({ | ||||||
|             next: (author: Author) => { |             next: (author: Author) => { | ||||||
|               this.cookieService.delete('author', '/', this.configurationService.getServerAddress()) |               this.cookieService.delete('author', '/', this.configurationService.getDomain()) | ||||||
|               this.cookieService.set("author", JSON.stringify(author), { |               this.cookieService.set("author", JSON.stringify(author), { | ||||||
|  |                 domain: this.configurationService.getDomain(), | ||||||
|                 secure : true, |                 secure : true, | ||||||
|                 path: '/' }); |                 path: '/' }); | ||||||
|               this.cookieService.set('token-expiration-date', DateTime.now().plus({millisecond: this.configurationService.getTokenTTL()}).toISO(), { |               this.cookieService.set('token-expiration-date', DateTime.now().plus({millisecond: this.configurationService.getTokenTTL()}).toISO(), { | ||||||
|  |                 domain: this.configurationService.getDomain(), | ||||||
|                 secure: true, |                 secure: true, | ||||||
|                 path: '/', |                 path: '/', | ||||||
|               }) |               }) | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ export class LogoutComponent implements OnInit{ | |||||||
|     const routes: string[] = ['/', '/login', '/register', '/logout', '/profile', '/post', '/new-post', '/admin'] |     const routes: string[] = ['/', '/login', '/register', '/logout', '/profile', '/post', '/new-post', '/admin'] | ||||||
|     Object.keys(this.cookieService.getAll()).forEach(key => { |     Object.keys(this.cookieService.getAll()).forEach(key => { | ||||||
|       routes.forEach(route => { |       routes.forEach(route => { | ||||||
|         this.cookieService.delete(key, route, this.configurationService.getServerAddress()); |         this.cookieService.delete(key, route, this.configurationService.getDomain()); | ||||||
|       }) |       }) | ||||||
|     }); |     }); | ||||||
|     this.router.navigate(['/']).then(() => this.successMessage('Déconnexion', 'Vous avez été deconnecté avec succès')); |     this.router.navigate(['/']).then(() => this.successMessage('Déconnexion', 'Vous avez été deconnecté avec succès')); | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| <!doctype html> | <!doctype html> | ||||||
| <html lang="en"> | <html lang="en"> | ||||||
|  | 
 | ||||||
| <head> | <head> | ||||||
|   <meta charset="utf-8"> |   <meta charset="utf-8"> | ||||||
|   <title>A BON ENTENDEUR</title> |   <title>A BON ENTENDEUR</title> | ||||||
| @ -7,17 +8,20 @@ | |||||||
|   <meta name="viewport" content="width=device-width, initial-scale=1"> |   <meta name="viewport" content="width=device-width, initial-scale=1"> | ||||||
|   <link rel="icon" type="image/x-icon" href="icon.jpg"> |   <link rel="icon" type="image/x-icon" href="icon.jpg"> | ||||||
| </head> | </head> | ||||||
|  | 
 | ||||||
| <body> | <body> | ||||||
| <app-root></app-root> | <app-root></app-root> | ||||||
| <footer class="footer"> | <footer class="footer"> | ||||||
|   <p class="footer-creator">Site web réalisé par <strong>Guams</strong>.</p> |   <p class="footer-creator">Site web réalisé par <strong>Guams</strong>.</p> | ||||||
|     <p class="footer-banner">Bannière réalisée par <a href="https://x.com/Orabisss" target="_blank" class="footer-link">@Orabisss</a> sur Twitter.</p> |   <p class="footer-banner">Bannière réalisée par <a href="https://x.com/Orabisss" target="_blank" | ||||||
|  |                                                     class="footer-link">@Orabisss</a> sur Twitter.</p> | ||||||
|   <p class="footer-follow">Suivez-moi sur :</p> |   <p class="footer-follow">Suivez-moi sur :</p> | ||||||
|   <p class="footer-links"> |   <p class="footer-links"> | ||||||
|     <a href="https://x.com/Guams8" target="_blank" class="footer-link">Twitter</a> |     <a href="https://x.com/Guams8" target="_blank" class="footer-link">Twitter</a> | ||||||
|     <a href="https://github.com/Guamss" target="_blank" class="footer-link">GitHub</a> |     <a href="https://github.com/Guamss" target="_blank" class="footer-link">GitHub</a> | ||||||
|  |     <a href="https://gitea.guams.fr" target="_blank" class="footer-link">Gitea</a> | ||||||
|   </p> |   </p> | ||||||
|     <p class="footer-copyright">© 2024 Guams. Tous droits réservés.</p> |  | ||||||
| </footer> | </footer> | ||||||
| </body> | </body> | ||||||
|  | 
 | ||||||
| </html> | </html> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user