envoyer carte sans auth guard

thierry
Tmadkaud 7 years ago
parent 703cda9764
commit 22fa4127a1

@ -10,6 +10,7 @@ import { ScannerCarteComponent } from './components/opCommercial/scanner-carte/s
import { EditProfilComponent } from './components/profil/edit-profil/edit-profil.component'
import { DebiterCarteComponent } from './components/opCommercial/debiter-carte/debiter-carte.component';
import { CarteEnvoyerComponent } from './components/carteParrainage/carte-envoyer/carte-envoyer.component';
import {AuthGuard} from './core/auth.guard';
@ -19,10 +20,10 @@ export const AppRoutes = [
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: 'profil', component: ProfilComponent, canActivate: [AuthGuard]},
{path: 'opCommercial', component: OpCommercialComponent, canActivate: [AuthGuard]},
{path: 'opCommercial', component: OpCommercialComponent},
{path: 'creationOpCommercial', component: CreationOpComComponent, canActivate: [AuthGuard]},
{path: 'carteParrainageComponent', component: CarteParrainageComponent, canActivate: [AuthGuard]},
{path: 'EnvoyerCarte/:idOp', component: EnvoyerCarteComponent, canActivate: [AuthGuard]},
{path: 'EnvoyerCarte/:idOp', component: EnvoyerCarteComponent},
{path: 'scannerCarte/:idOp', component: ScannerCarteComponent, canActivate: [AuthGuard]},
{path: 'debiterCarte/:idOp', component: DebiterCarteComponent, canActivate: [AuthGuard]},
{path: 'editProfil', component: EditProfilComponent, canActivate: [AuthGuard]},

@ -3,7 +3,7 @@
<h4 class="h5 text-center mb-4" style="padding-top: 5%;">Historique des cartes envoyées</h4>
<!--<button class="btn btn-primary btn-rounded waves-light" (click)="goToOpCom()">Retour aux Opérations commerciales</button>-->
<div class="list-group">
<div *ngFor="let crt of carteParData | async; let i = index;">
<div *ngFor="let crt of (carteParData | async); let i = index;">
<div class="card mainCard">
<div class="row" id="testt">
<img class="col-md-6 card-image mb-1 subCard1" id="image1" alt="Responsive image" src={{crt.carteTemplate.downloadURL}}>

@ -107,13 +107,13 @@ export class CarteEnvoyerComponent implements OnInit {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
// this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
//this.router.navigate(['/']);
}
}

@ -114,13 +114,12 @@ export class CarteParrainageComponent implements OnInit, OnDestroy {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
// this.router.navigate(['/']);
}
}
goToProfil(){

@ -31,7 +31,7 @@ export class LoginComponent implements OnInit, OnDestroy {
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService) {
this.user = afAuth.authState;
this.email = '';
this.password = '';
this.myUser = new User();
@ -51,6 +51,20 @@ export class LoginComponent implements OnInit, OnDestroy {
ngOnInit() {
/*try {
this.user.subscribe(
(auth) => {
if (auth.email !== this.email) {
this.router.navigate(['/']);
} else {
console.log('aucun user connecté');
}
});
} catch (e) {
// No content response..
console.log(e);
console.log('aucun user connecté');
}*/
}
ngOnDestroy() {

@ -90,7 +90,7 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
//this.router.navigate(['/']);
}
}
goToOpComm() {

@ -167,13 +167,13 @@ export class DebiterCarteComponent implements OnInit, OnDestroy {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
//this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
//this.router.navigate(['/']);
}
}
//////

@ -165,7 +165,7 @@
</div>
</div>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-light-green waves-light" [disabled]="(parSelect === '') || (birthdayTemp !== parrain.birthday)" (click)="creerCartePar()">Envoyer Carte à {{parSelect}}</button>
<button class="btn btn-light-green waves-light" [disabled]="(parSelect === '') || (birthdayTemp !== parrain.birthday)" (click)="creerCartePar()">Envoyer Carte {{parSelect}}</button>
<button class="btn btn-cyan" (click)="goToOpComm()">Back</button>
</div>
</div>

@ -61,8 +61,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
yearTest: number;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService,
private opComService: OpCommercialService, private route: ActivatedRoute) {
private router: Router, private route: ActivatedRoute) {
this.user = afAuth.authState;
@ -212,13 +211,19 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
userRef.set(this.parrain);
console.log('crer par: '+ this.parrain.firstname);
// this.cartePar.parrainCarte = this.parrain;
this.getIdParrain(userCreate.uid);
console.log('creer par userCreate.uid: '+ userCreate.uid);
this.creerCartePar();
console.log('creer par creerCartePar: '+ this.cartePar.uid);
firebase.auth().sendPasswordResetEmail(this.parrain.email);
userCreate.sendEmailVerification();
console.log('avant logout firebase.auth().currentUser.uid: '+ firebase.auth().currentUser.uid);
firebase.auth().signOut();
firebase.auth().signInWithEmailAndPassword(this.commercant.email, this.commercant.password);
console.log('avant logout firebase.auth().currentUser.uid: '+ firebase.auth().currentUser.uid);
});
}
@ -230,6 +235,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
}
getIdParrain(parUid) {
console.log('parUid getidpar: '+ parUid);
const parlistTemp = this.afDb.list('/Parrain/', {
query: {
orderByChild: 'uid',
@ -241,10 +247,11 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
parlistTemp.forEach(par => {
par.forEach(elementParTemp => {
this.cartePar.parrainCarte = elementParTemp;
console.log('ttthis.cartePar.parrainCarte.uid: '+ this.cartePar.parrainCarte.uid + this.cartePar.parrainCarte.firstname);
});
});
this.selectPar = true;
console.log('this.cartePar.parrainCarte.uid: '+ this.cartePar.parrainCarte.uid + this.cartePar.parrainCarte.firstname);
if (this.radioParrain === 'Newparrain') {
this.parSelect = ' à : '
@ -285,14 +292,13 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
creerCartePar() {
// this.opComService.creerCartePar(this.cartePar); inutile
this.sectionToImage(this.cartePar);
console.log('this.opComm.nbEnvoie: ' + this.opComm.nbEnvoie);
this.opComm.nbEnvoie = ((+this.opComm.nbEnvoie) + 1).toString();
console.log('this.opComm.nbEnvoie: ' + this.opComm.nbEnvoie);
const opEnvRef = this.databaseRef.child('OperationCommercial').child(this.opComm.uid.toString()).child('nbEnvoie');
opEnvRef.set('this.opComm.nbEnvoie: ' + this.opComm.nbEnvoie);
opEnvRef.set(this.opComm.nbEnvoie);
this.validC = 'ok';
@ -351,21 +357,6 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
}
//////
ngOnInit() {
try {
this.user.subscribe(
(auth) => {
if (auth) {
this.subscription = this.opComService.getParrains()
.subscribe(parrains => this.parrainsTest = parrains);
} else {
this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
}
}
//////

@ -103,13 +103,13 @@ export class OpCommercialComponent implements OnInit, OnDestroy {
if (auth) {
console.log(auth.uid);
} else {
this.router.navigate(['/']);
// this.router.navigate(['/']);
}
});
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
// this.router.navigate(['/']);
}
}
ngOnDestroy() {}

@ -242,7 +242,7 @@ export class ScannerCarteComponent implements OnInit, OnDestroy {
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
// this.router.navigate(['/']);
}
this.subscription = this.opComService.getParrains()
.subscribe(parrains => this.filleulTest = parrains);

@ -107,7 +107,7 @@ export class ProfilComponent implements OnInit, OnDestroy {
} catch (e) {
// No content response..
console.log(e);
this.router.navigate(['/']);
//this.router.navigate(['/']);
}
}

@ -49,6 +49,12 @@ export class RegisterComponent implements OnInit, OnDestroy {
}
}
clean(){
this.ngOnDestroy();
this.currentUser.status = '';
this.test = false;
}
// On renvoie un nombre aléatoire entre une valeur min (incluse)
// et une valeur max (exclue)
getRandomArbitrary(min, max) {

Loading…
Cancel
Save