Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Yûki VACHOT 2021-12-06 05:40:45 +01:00
commit 4c1d954fba
12 changed files with 93 additions and 44 deletions

View file

@ -23,7 +23,7 @@
<!-- Mon profil -->
<img [src]=urlImage
<img [src]=profilService.profileImageUrl
onerror="this.onerror=null; this.src='assets/profil.png'"
[routerLink]="routes[3]"
alt="">

View file

@ -1,5 +1,7 @@
import {Component} from '@angular/core';
import {Router} from "@angular/router";
import {ProfilService} from "../../../utils/services/profil/profil.service";
import {MessageService} from "../../../utils/services/message/message.service";
@ -19,9 +21,20 @@ export class NavbarAdminComponent
url = this.router.url;
urlImage: string = "https://www.reference-gaming.com/assets/media/product/41195/figurine-pop-duck-tales-n-309-loulou.jpg?format=product-cover-large&k=1519639530" ;
constructor( private router: Router,
public profilService: ProfilService,
private messageService: MessageService ) { }
constructor(private router: Router) { }
onDeconnexion(): void
{
this.messageService
.delete('user/logout', {})
.subscribe(retour => this.onDeconnexionCallback(retour), err => this.onDeconnexionCallback(err));
}
onDeconnexionCallback(retour: any): void
{
console.log(retour);
}
onDeconnexion(): void {}
}

View file

@ -27,7 +27,7 @@
<!-- Mon profil -->
<img [src]=urlImage
<img [src]=profilService.profileImageUrl
onerror="this.onerror=null; this.src='assets/profil.png'"
[routerLink]="routes[4]"
alt="">

View file

@ -1,5 +1,7 @@
import { Component } from '@angular/core';
import {Router} from "@angular/router";
import {ProfilService} from "../../../utils/services/profil/profil.service";
import {MessageService} from "../../../utils/services/message/message.service";
@ -20,9 +22,20 @@ export class NavbarAdvertiserComponent
url = this.router.url;
urlImage: string = "https://www.figurines-goodies.com/1188-large_default/dewey-duck-tales-disney-funko-pop.jpg" ;
constructor( private router: Router,
public profilService: ProfilService,
private messageService: MessageService ) { }
constructor(private router: Router) { }
onDeconnexion(): void
{
this.messageService
.delete('user/logout', {})
.subscribe(retour => this.onDeconnexionCallback(retour), err => this.onDeconnexionCallback(err));
}
onDeconnexionCallback(retour: any): void
{
console.log(retour);
}
onDeconnexion(): void {}
}

View file

@ -5,6 +5,7 @@ import {ThemeService} from "../../../utils/services/theme/theme.service";
import {MatDialog} from "@angular/material/dialog";
import {PopupForgottenPasswordComponent} from "../popup-forgotten-password/popup-forgotten-password.component";
import {MatSnackBar} from "@angular/material/snack-bar";
import {ProfilService} from "../../../utils/services/profil/profil.service";
@ -25,7 +26,8 @@ export class PageLoginComponent implements OnInit
private router: Router,
public themeService: ThemeService,
public dialog: MatDialog,
private snackBar: MatSnackBar ) { }
private snackBar: MatSnackBar,
private profilService: ProfilService) { }
ngOnInit(): void {}
@ -50,12 +52,16 @@ export class PageLoginComponent implements OnInit
onSeConnecterCallback(retour): void
{
console.log(retour);
if(retour.status !== "success") {
this.errorMessage = retour.error.data.reason;
this.hasError = true;
}
else {
this.router.navigateByUrl( '/user/search');
this.profilService.profileImageUrl = retour.data.profileImageUrl;
if(retour.data.role.name === "user") this.router.navigateByUrl( '/user/search');
else if(retour.data.role.name === "advertiser") this.router.navigateByUrl( '/advertiser/adList');
else if(retour.data.role.name === "admin") this.router.navigateByUrl( '/admin/userList');
}
}

View file

@ -1,4 +1,4 @@
<h4>Oubli mot de passe</h4>
<h4>Récupération du mot de passe</h4>
<mat-divider></mat-divider><br>

View file

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import {MessageService} from "../../../utils/services/message/message.service";
import {Router} from "@angular/router";
import {MatDialog} from "@angular/material/dialog";
@ -55,27 +55,18 @@ export class PageRegisterComponent
{
if(this.user.role.name === "user") this.user.role.permission = 0;
else this.user.role.permission = 5;
this.user.hashPass = this.hashage(this.password);
// FAUX CODE
const retour = { status: "succes" };
this.myCallback(retour);
// VRAI CODE
/*
this.user.hashPass = this.password;
this.messageService
.sendMessage('register', this.user)
.subscribe(retour => this.myCallback(retour));
*/
.post('user/create', this.user)
.subscribe(retour => this.onEnregistrerCallback(retour), err => this.onEnregistrerCallback(err));
}
}
// Gestion de la réponde du backend
myCallback(retour): void
{
if(retour.status === "error")
onEnregistrerCallback(retour): void
{
if(retour.status !== "success") {
console.log(retour);
}
else
@ -140,17 +131,4 @@ export class PageRegisterComponent
this.user.interests = myInterets;
}
// Fonction de hashage (faible)
hashage(input: string): string
{
let hash = 0;
for (let i = 0; i < input.length; i++) {
let ch = input.charCodeAt(i);
hash = ((hash << 5) - hash) + ch;
hash = hash & hash;
}
return hash.toString();
}
}

View file

@ -1,6 +1,8 @@
import {Component, Inject} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
@Component({
selector: 'app-popup-confirmation',
templateUrl: './popup-confirmation.component.html',
@ -10,5 +12,4 @@ export class PopupConfirmationComponent
{
constructor( public dialogRef: MatDialogRef<PopupConfirmationComponent>,
@Inject(MAT_DIALOG_DATA) public data) {}
}

View file

@ -27,7 +27,7 @@
<!-- Mon profil -->
<img [src]=urlImage
<img [src]=profilService.profileImageUrl
onerror="this.onerror=null; this.src='assets/profil.png'"
[routerLink]="routes[4]"
alt="">

View file

@ -1,5 +1,7 @@
import {Component} from '@angular/core';
import {Router} from "@angular/router";
import {ProfilService} from "../../../../utils/services/profil/profil.service";
import {MessageService} from "../../../../utils/services/message/message.service";
@ -20,9 +22,20 @@ export class NavbarUserComponent
url = this.router.url;
urlImage: string = "https://www.figurines-goodies.com/1185-thickbox_default/huey-duck-tales-disney-funko-pop.jpg" ;
constructor( private router: Router,
public profilService: ProfilService,
private messageService: MessageService ) { }
constructor(private router: Router) { }
onDeconnexion(): void
{
this.messageService
.delete('user/logout', {})
.subscribe(retour => this.onDeconnexionCallback(retour), err => this.onDeconnexionCallback(err));
}
onDeconnexionCallback(retour: any): void
{
console.log(retour);
}
onDeconnexion(): void {}
}

View file

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ProfilService } from './profil.service';
describe('ProfilService', () => {
let service: ProfilService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ProfilService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View file

@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ProfilService
{
public profileImageUrl: string = "";
}