merge dev->thomas

This commit is contained in:
Thomas Cardon 2022-03-07 16:24:48 +01:00
commit 8f3d2669e5
37 changed files with 621 additions and 78 deletions

View File

@ -114,7 +114,6 @@ export class AddRestauComponent implements OnInit {
restaurant.adresse !== '') {
this.apiBackService.addRestaurant(restaurant).subscribe(
resp =>
this.router.navigate(['restaurants'])
);
} else {

View File

@ -15,9 +15,7 @@ export class UpdateDelRestauComponent implements OnInit {
this.restauList = [];
}
ngOnInit(): void {
}
ngOnInit(): void {}
saveRestauList(event : any){
@ -28,10 +26,7 @@ export class UpdateDelRestauComponent implements OnInit {
deleteRestau(idRestau : number | undefined){
this.apiBackService.deleteRestau(idRestau).subscribe(
resp =>{
this.restauList = this.restauList.filter(restaus => restaus.id != idRestau)
});
}

View File

@ -7,16 +7,20 @@ import { RestoPageComponent } from './pages/resto-page/resto-page.component';
import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.component';
import { FiltersPageComponent } from './pages/filters-page/filters-page.component';
import { SigninComponent } from './pages/signin/signin.component';
import { SignupComponent } from './pages/signup/signup.component';
import { AdminPageComponent } from './pages/admin-page/admin-page.component';
import { AuthGuard } from './services/auth.guard';
import { PageAccountComponent } from './pages/page-account/page-account.component';
const routes: Routes = [
{ path: '', redirectTo: 'signin', pathMatch: 'full' },
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{path: 'signin', component: SigninComponent},
{path: 'signup', component: SignupComponent},
{ path: 'home', component: HomePageComponent },
{ path: 'categories', component: ListCategoriesComponent },
{ path: 'favoris', component: FavorisUserComponent },
{ path: 'filtres', component: FiltersPageComponent },
{ path: 'profil', component: PageAccountComponent },
{ path: 'Deconnexion', redirectTo: 'home'},
{path: 'restaurants', canActivate: [AuthGuard], /*data : {ROLE : "ROLE_ADMIN"},*/ component: RestoPageComponent},
{path: 'page-not-found',component: PageNotFoundComponent},

View File

@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { ApiBackService } from './services/api-back.service';
import { AuthGuard } from './services/auth.guard';
@Component({
selector: 'app-root',
@ -11,7 +12,7 @@ export class AppComponent {
title = 'simpleat';
dontShow: boolean = false;
constructor(public router:Router, private apiBackService : ApiBackService){
constructor(public router:Router, private apiBackService : ApiBackService, private authgard : AuthGuard){
this.router.events.subscribe(e=>{
//console.log(e);
if(e instanceof NavigationEnd){
@ -26,6 +27,7 @@ export class AppComponent {
}
ngOnInit(): void { }
ngOnInit(): void {}
}
}

View File

@ -24,6 +24,8 @@ import { UpdateDelRestauComponent } from './admin-component/update-del-restau/up
import { HeaderLogoComponent } from './header/components/header-logo/header-logo.component';
import { AuthInterceptor } from './services/auth.interceptor';
import { FavorisUserComponent } from './pages/favoris-user/favoris-user.component';
import { SignupComponent } from './pages/signup/signup.component';
import { PageAccountComponent } from './pages/page-account/page-account.component';
@NgModule({
declarations: [
@ -46,7 +48,9 @@ import { FavorisUserComponent } from './pages/favoris-user/favoris-user.componen
AddRestauComponent,
UpdateDelRestauComponent,
HeaderLogoComponent,
FavorisUserComponent
FavorisUserComponent,
SignupComponent,
PageAccountComponent
],
imports: [
BrowserModule,

View File

@ -10,4 +10,5 @@
<p>LE BON PLAN POUR MANGER</p>
</div>
</div>
</nav>

View File

@ -10,6 +10,7 @@
}
.trait{
width: 100%;
@ -27,3 +28,11 @@ p{
padding : 0 10px 0 10px;
color: grey;
}
@media only screen and (max-width:753px) {
.trait{
display: none;
}
}

View File

@ -9,13 +9,14 @@
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="nav">
<div class="navbar-nav ">
<div class="collapse navbar-collapse justify-content-end" id="navbarNavAltMarkup">
<div class="navbar-nav navbar-light">
<a routerLink="home" routerLinkActive="active-custom" class="nav-link p-4 pe-5 " style="font-size: 21px;">Accueil</a>
<a routerLink="categories" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Categories</a>
<a routerLink="restaurants" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Restaurants</a>
<a routerLink="filtres" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Filtres</a>
<a routerLink="favoris" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Mes favoris</a>
<a routerLink="profil" routerLinkActive="active-custom" class="nav-link p-4 pe-5" style="font-size: 21px;">Mon profil</a>
<a routerLink="deconnexion" routerLinkActive="active-custom" (click) = "onCloseSession()" class="nav-link p-4 pe-5" style="font-size: 21px;">Deconnexion</a>
</div>
</div>
@ -23,7 +24,6 @@
<div id="image-header">
<img src="assets/images-header/bandeau2.png" alt="fond_header">
</div>
</nav>

View File

@ -1,13 +1,15 @@
#image-header{
display: flex;
justify-content: center;
}
img{
width: 100%;
display: block;
height: auto;
margin: 0 auto;
padding: 0;
@ -23,3 +25,14 @@ img{
@media only screen and (max-width:1131px) {
.navbar-toggler{
margin: 3vh;
}
.container-fluid{
padding: 0;
}
}

View File

@ -9,9 +9,14 @@ import { environment } from 'src/environments/environment';
styleUrls: ['./nav-bar.component.scss']
})
export class NavBarComponent implements OnInit {
tokenKey = environment.tokenKey;
constructor( private tokenService : TokenService, public route: Router) { }
private tokenKey: string;
constructor( private tokenService : TokenService, public route: Router) {
this.tokenKey = environment.tokenKey;
}
ngOnInit(): void {
}

View File

@ -1,5 +1,5 @@
<form class="d-flex align-items-center pe-2 pt-2">
<input class="form-control me-5 position-relative" type="search" #newItem placeholder="Trouver votre SIMPL'EAT..."
<form class="content d-flex align-items-center pe-3 pt-2">
<input class="search form-control me-2 position-relative" type="search" #newItem placeholder="Trouver votre SIMPL'EAT..."
aria-label="Search">
<button type="button" class="btn btn-outline-danger" (click)="onChangeInput(newItem.value)">Recherche</button>
</form>

View File

@ -1,4 +1,19 @@
input[type="search"], textarea{
background-color: #edf5f1;
}
@media only screen and (max-width:753px) {
.content{
margin-left: 3vh;
margin-top: 3vh;
}
// .btn{
// display: none;
// }
}

View File

@ -5,5 +5,10 @@
<div class="search-bar">
<app-update-del-restau ></app-update-del-restau>
</div>
<div>
<app-signup></app-signup>
</div>
</div>
</div>

View File

@ -1,3 +0,0 @@
.search-bar{
width : 30%;
}

View File

@ -8,7 +8,7 @@
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingOne">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
<button class="btn shadow accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseOne">
<p style="font-family:'Roboto';font-size: 20px;">Distance</p>
</button>
@ -36,7 +36,7 @@
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingTwo">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
<button class="btn shadow accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseTwo">
<p style="font-family:'Roboto'; font-size: 20px;">Prix</p>
</button>
@ -64,7 +64,7 @@
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingThree">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
<button class="btn shadow accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseThree">
<p style="font-family:'Roboto'; font-size: 20px;">Sur Place / A Emporter</p>
</button>
@ -91,7 +91,7 @@
<div class="accordion-item">
<h2 class="accordion-header" id="panelsStayOpen-headingFour">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
<button class="btn shadow accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseFour">
<p style="font-family:'Roboto'; font-size: 20px;">Accès PMR</p>
</button>

View File

@ -8,21 +8,18 @@
.titre{
display: flex;
justify-content: flex-start;
margin: 2.5em 0 0.5em 8.2em;
color: #CE0000;
}
.accordion{
padding-top: 100px;
max-width: 30%;
max-width: 40%;
margin : 0 auto;
margin-bottom: 100px;
}
.accordion-body{
@ -56,8 +53,28 @@ filter: drop-shadow(0 0 0.2rem grey);
}
span{
font-weight: 500 ;
}
.accordion-button.collapsed {
background: #CE0000;
}
.accordion-button.collapsed::after {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}
@media only screen and (max-width:768px) {
span{
font-size: 2vh;
}
p{
font-size: 2vh;
}
}

View File

@ -1 +1,50 @@
<h1 style = "text-align: center;">Hello {{userName}} !</h1>
<div class="body">
<h1 style = "text-align: center; font-family: 'Dancing Script', cursive; font-size: 7vh;">Hello {{userName}} !</h1>
<div class="intro d-flex justify-content-center pt-4 m-3 "style = "font-size: 2.6vh; font-style:italic;">
<span class=" preface">Bienvenue sur Simpl'eat, l'application indispensable pour un Simplonien comme toi !</span>
</div>
<div class="separation"></div>
<div class="premier_bloc">
<img src="assets/imagesAccueil/image_accueil_1 1.png" alt="Photo d'un magnifique repas miam ! ">
<p class="uno">Cette application à été conçue dans le but de te permettre de visualiser les différents restaurants aux alentours de lécole SIMPLON située à MONTREUIL.
Tu pourras choisir choisir selon tes préférences un restaurant en particulier qui convient selon ton envie du jour.
Une boulangerie, un kebab, une pizzeria ou simplement un magnifique sandwich triangle dans ton cente commercial préféré !
C'est pas magnifique ça ?</p>
</div>
<div class="ligne-rouge">
<div class="separation2"></div>
</div>
<div class="deuxieme_bloc">
<p class="dos">L'idée de cette application vient du fait qu'en tant que provincial, d'arriver dans une nouvelle ville, d'être presque perdu dans un environnement
qui nous ait inconnu, de ne pas savoir si il y a le meilleur kebab du coin dans les environs ?
Toutes ces pensées nous envahissent et nous ont amener à concevoir ceci pour vous !</p>
<img src="assets/imagesAccueil/image_accueil_2 1.png" alt="Photo d'un magnifique repas miam ! ">
</div>
<div class="separation"></div>
<div class="troisieme_bloc">
<img src="assets/imagesAccueil/image_accueil_3 1.png" alt="Photo d'un magnifique repas miam ! ">
<ul>
<p class="tres">Sur cette application, plusieurs fonctionnalités s'offre à toi :</p>
<li>Acceder aux différents restaurants répertoriés sur l'application ! </li>
<li>Choisir la catégorie de restaurants qui donne le plus envie ! </li>
<li>Sélectionner et préserver en favoris les restaurants dont tu veux garder l'adresse ! </li>
</ul>
</div>
<div class = "intro d-flex justify-content-center pt-5 "style = "text-align: center; font-family: 'Dancing Script';font-size: 7vh;">
A toi de jouer !
</div>
</div>

View File

@ -1,7 +1,165 @@
#demotext {
color: #FFFFFF;
background: #912C22;
text-shadow: 0 0 10px #FFFFFF;
color: #FFFFFF;
background: #912C22;
.body{
width: 100%;
padding: 8vh 20vh;
}
h1{
font-size: 4vh;
padding-top: 3vh;
}
.preface{
text-align: center;
padding-bottom: 3vh;
}
.premier_bloc{
display: flex;
align-items: center;
}
.deuxieme_bloc{
display: flex;
align-items: center;
}
.troisieme_bloc{
display: flex;
align-items: center;
}
img{
margin: 5vh 0 0 0;
border-radius: 10px;
width: 100%;
max-width: 500px;
height: auto;
}
.uno{
padding-top: 6vh;
padding-left: 6vh;
text-align: justify;
}
.dos{
padding-top: 6vh;
padding-right: 6vh;
text-align: justify;
}
.tres{
padding-top: 6vh;
font-size: 3.5vh;
}
.separation{
display: flex;
justify-content: flex-start;
border-bottom: 2px solid #CE0000;
max-width: 83%;
padding : 20px;
}
.ligne-rouge{
display: flex;
justify-content: flex-end;
}
.separation2{
border-bottom: 2px solid #CE0000;
max-width: 83%;
width: 100%;
padding : 20px;
}
@media only screen and (max-width:1131px) {
.body{
display: flex;
justify-content: center;
margin: -1vh auto;
padding: 3vh;
flex-wrap: wrap;
}
img{
width: 100%;
max-width: 500px;
height: auto;
padding-bottom: 5vh;
border-radius: 10px;
display: flex;
justify-content: center;
}
.premier_bloc{
flex-wrap: wrap;
}
.deuxieme_bloc{
flex-wrap: wrap;
flex-direction: column-reverse;
}
.troisieme_bloc{
flex-wrap: wrap;
}
.uno{
padding-top: 0;
padding-left: 0;
padding-bottom: 2.5vh;
text-align: justify;
}
.dos{
padding-top: 0;
padding-right: 0;
padding-bottom: 2.5vh;
text-align: justify;
}
.tres{
padding-top: 0;
font-size: 3.5vh;
}
.separation{
display: flex;
justify-content: center;
border-bottom: 1px solid #CE0000;
width: 100%;
padding: 0;
}
.ligne-rouge{
display: flex;
justify-content: center;
width: 100%;
}
.separation2{
padding: 0;
border-bottom: 1px solid #CE0000;
max-width: 83%;
}
}

View File

@ -11,19 +11,13 @@ export class HomePageComponent implements OnInit {
public userName : any;
constructor(private apiBackService : ApiBackService, private tokenService : TokenService) {
}
constructor(private apiBackService : ApiBackService, private tokenService : TokenService) {}
ngOnInit(): void {
this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()).subscribe(
user =>{
this.userName = user.prenom;
})
}

View File

@ -0,0 +1,5 @@
export enum RoleList {
ROLE_ADMIN = 'ROLE_ADMIN',
ROLE_CREATOR = 'ROLE_CREATOR',
ROLE_READER = 'ROLE_READER'
}

View File

@ -5,4 +5,5 @@ export interface User {
email: string;
password?: string;
preference ?: object;
roleList ?: string[];
}

View File

@ -0,0 +1,20 @@
<div class="container mt-5">
<form class="row g-2" [formGroup]="userInfo">
<div class="col-md-6">
<label for="inputFirstName" class="form-label">Prénom</label>
<input type="text" class="form-control" id="inputFirstName" formControlName="firstName" readonly="readonly">
</div>
<div class="col-md-6">
<label for="inputLastName" class="form-label">Nom</label>
<input type="text" class="form-control" id="inputLastName" formControlName="lastName" readonly="readonly">
</div>
<div class="col-md-6">
<label for="inputEmail" class="form-label">Email</label>
<input type="email" class="form-control" id="inputEmail" formControlName="email" readonly="readonly">
</div>
<div class="col-md-6">
<label for="inputEmail" class="form-label">Role</label>
<input type="RoleList" class="form-control" id="inputRoleList" formControlName="RoleList" readonly="readonly">
</div>
</form>
</div>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PageAccountComponent } from './page-account.component';
describe('PageAccountComponent', () => {
let component: PageAccountComponent;
let fixture: ComponentFixture<PageAccountComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PageAccountComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PageAccountComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,38 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { AuthService } from 'src/app/services/auth.service';
import { RoleList } from '../models/roleList';
import { User } from '../models/user';
@Component({
selector: 'app-page-account',
templateUrl: './page-account.component.html',
styleUrls: ['./page-account.component.scss']
})
export class PageAccountComponent implements OnInit {
public userInfo: FormGroup;
constructor(private fb: FormBuilder, private authService: AuthService) {
this.userInfo = this.initForm();
this.authService.getConnectedUserInfo()?.subscribe(
(user: User) => {
this.userInfo = this.initForm(user);
}
)
}
ngOnInit(): void {
}
private initForm(user?: User): FormGroup {
return this.fb.group({
firstName: [user ? user.prenom : ''],
lastName: [user ? user.nom : ''],
email: [user ? user.email : ''],
RoleList: [user ? user.roleList : '']
})
}
}

View File

@ -1,7 +1,6 @@
<div class="signin-form text-center">
<main class="form-signin d-inline-flex">
<form (ngSubmit)="onSubmit(signinForm)" #signinForm="ngForm">
<h5>Merci de vous connecter</h5>
<img src="../../../assets/images-header/logo.png"><br>
<br>Le bon plan pour manger<br>
<div class="form-floating">

View File

@ -0,0 +1,71 @@
<div class="signup-form text-center">
<main class="form-signup">
<form (ngSubmit)="onSubmit()" [formGroup]="signupForm">
<h1>Inscription d'un membre</h1>
<div class="form-floating">
<input type="text"
class="form-control"
id="floatingInputfirstName"
placeholder=""
name="firstName"
formControlName="firstNameFc"
[ngClass]="{'is-valid' : signupForm.controls['firstNameFc'].touched && signupForm.controls['firstNameFc'].valid,
'is-invalid': signupForm.controls['firstNameFc'].touched && !signupForm.controls['firstNameFc'].valid}">
<label for="floatingInputfirstName">Prénom</label>
</div>
<div class="form-floating">
<input type="text"
class="form-control"
id="floatingInputlastName"
placeholder=""
name="lastName"
formControlName="lastNameFc"
[ngClass]="{'is-valid' : signupForm.controls['lastNameFc'].touched && signupForm.controls['lastNameFc'].valid,
'is-invalid': signupForm.controls['lastNameFc'].touched && !signupForm.controls['lastNameFc'].valid}">
<label for="floatingInputlastName">Nom</label>
</div>
<div class="form-floating">
<input type="email"
class="form-control"
id="floatingInput"
placeholder=""
name="email"
formControlName="emailFc"
[ngClass]="{'is-valid' : signupForm.controls['emailFc'].touched && signupForm.controls['emailFc'].valid,
'is-invalid': signupForm.controls['emailFc'].touched && !signupForm.controls['emailFc'].valid}">
<label for="floatingInput">Adresse email **</label>
</div>
<div class="form-floating">
<input type="password"
class="form-control"
id="floatingPassword"
placeholder=""
name="password"
formControlName="passwordFc"
[ngClass]="{'is-valid' : signupForm.controls['passwordFc'].touched && signupForm.controls['passwordFc'].valid,
'is-invalid': signupForm.controls['passwordFc'].touched && !signupForm.controls['passwordFc'].valid}">
<label for="floatingPassword">Mot de passe **</label>
</div>
<div class="form-floating">
<select class="form-select" id="roleList" formControlName="roleFc">
<option *ngFor="let c of roleList | keyvalue" value={{c.value}}>{{c.value}}</option>
</select>
<label for="roleList">Selectionner un rôle **</label>
</div>
<div *ngIf="alertMessage" class="alert alert-danger">
<p class="alert-link">{{alertMessage}}</p>
</div>
<div *ngIf="successMessage" class="alert alert-success">
<p class="alert-link">{{successMessage}}</p>
</div>
<button class="w-100 btn btn-lg btn-success"
type="submit"
[disabled]="signupForm.invalid">Inscription</button>
</form>
</main>
</div>

View File

@ -0,0 +1,31 @@
.signup-form {
height: 100vh;
padding-top: 40px;
}
.form-signup {
width: 100%;
max-width: 330px;
padding: 15px;
margin: auto;
}
.form-signup .checkbox {
font-weight: 400;
}
.form-signup .form-floating:focus-within {
z-index: 2;
}
.form-signup input[type="email"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-signup input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SignupComponent } from './signup.component';
describe('SignupComponent', () => {
let component: SignupComponent;
let fixture: ComponentFixture<SignupComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SignupComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SignupComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,69 @@
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { AuthService } from 'src/app/services/auth.service';
import { RoleList } from '../models/roleList';
import { User } from '../models/user';
@Component({
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.scss']
})
export class SignupComponent implements OnInit {
public signupForm: FormGroup;
public roleList: typeof RoleList;
public alertMessage?: string;
public successMessage?: string;
constructor(private authService: AuthService, private router: Router) {
this.signupForm = new FormGroup({});
this.roleList = RoleList;
}
ngOnInit(): void {
// FormGroupe => Group de champs de saisie (notre objet)
// FormControl => Les champs de saisie (nos propriétés)
this.signupForm = new FormGroup({
firstNameFc : new FormControl(''),
lastNameFc : new FormControl(''),
emailFc : new FormControl('', [Validators.email, Validators.required, Validators.pattern(/^([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/igm)]), // chercher une meilleure regex
passwordFc : new FormControl('', [Validators.minLength(8), Validators.required]),
roleFc : new FormControl('')
})
console.log(this.roleList);
}
public onSubmit(): void {
if(confirm("Êtes-vous sur d'ajouter ce membre ?")){
const firstNameValue = this.signupForm.value['firstNameFc'];
const lastNameValue = this.signupForm.value['lastNameFc'];
const emailValue = this.signupForm.value['emailFc'];
const passwordValue = this.signupForm.value['passwordFc'];
const roleValue = this.signupForm.value['roleFc'];
const user: User = {
prenom: firstNameValue,
nom: lastNameValue,
email: emailValue,
password: passwordValue,
roleList : [roleValue]
}
if(user.email !== '' && user.password !== '') {
this.authService.signup(user).subscribe(
resp => {
this.successMessage = "Membre ajouté !";
}
)
} else {
this.alertMessage = "Erreur d'ajout !";
}
}
}
}

View File

@ -3,6 +3,9 @@ import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { User } from 'src/app/pages/models/user';
import jwt_decode from 'jwt-decode';
import { Router } from '@angular/router';
@Injectable({
@ -12,24 +15,16 @@ export class AuthService {
private apiUrl: string;
private tokenKey: string;
constructor(private http: HttpClient) {
constructor(private http: HttpClient, private router: Router) {
// On se sert des variables d'environnement de notre application
this.apiUrl = environment.apiUrl;
this.tokenKey = environment.tokenKey;
}
// signup(): Observable<any> {
// // const body = {
// // firstName: firstName,
// // lastName: lastName,
// // email: email,
// // password: password
// // };
signup(newUser: User): Observable<any> {
return this.http.post(`${this.apiUrl}/signup`, newUser);
}
// console.log("Mon nouvel utilisateur : ", newUser);
// return this.http.post(`${this.apiUrl}/register`, newUser);
// }
signin(email: string, password: string): Observable<any> {
const body = {
@ -37,12 +32,6 @@ export class AuthService {
password: password
};
console.log("Mon body : ", body);
// Modifier cette partie ci-dessous :
// - pour pouvoir stocker dans le localstorage notre accesstoken
// - Sous la clé "TOKEN-SIMPLEAT"
return this.http.post(`${this.apiUrl}/signin`, body).pipe(
map((x: any) => {
console.log(x);
@ -56,15 +45,12 @@ export class AuthService {
);
}
// forgotPassword(email: string, password: string): Observable<any> {
// const body = {
// email: email,
// password: password
// };
// console.log("Mon body : ", body);
// return this.http.post(`${this.apiUrl}/forgot-psw`, body);
// }
getConnectedUserInfo(): Observable<User> | void {
const token = localStorage.getItem(this.tokenKey);
if(token) {
const decodedToken = jwt_decode<any>(token);
const userId = decodedToken.userId;
return this.http.get<User>(`${this.apiUrl}/user/${userId}`);
}
}
}

View File

@ -33,8 +33,13 @@ export class TokenService {
}
<<<<<<< HEAD
public destroyToken(tokenKey : string): void {
localStorage.removeItem(tokenKey);
localStorage.removeItem('ROLE');
=======
public destroyToken(token : any) {
localStorage.removeItem(token);
>>>>>>> dev
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 KiB

View File

@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
</head>
<body>