Merge branch 'thierry' of ssh://git.marbelium.com:10023/Viiciouss/XJC into anis

thierry
Viiciouss 7 years ago
commit aeb5f61900

@ -38,6 +38,7 @@ import { ListeOpCommercialComponent } from './components/admin/liste-op-commerci
import { DemandeOpCommercialComponent } from './components/admin/demande-op-commercial/demande-op-commercial.component';
import { ListCarteEnvoyerComponent } from './components/admin/list-carte-envoyer/list-carte-envoyer.component';
import { ListScanEffecterComponent } from './components/admin/list-scan-effecter/list-scan-effecter.component';
import { ResetPasswordComponent } from './components/home/reset-password/reset-password.component';
@ -63,7 +64,8 @@ import { ListScanEffecterComponent } from './components/admin/list-scan-effecter
ListeOpCommercialComponent,
DemandeOpCommercialComponent,
ListCarteEnvoyerComponent,
ListScanEffecterComponent
ListScanEffecterComponent,
ResetPasswordComponent
],
imports: [
BrowserModule,

@ -17,6 +17,7 @@ import { ListeOpCommercialComponent } from './components/admin/liste-op-commerci
import { DemandeOpCommercialComponent } from './components/admin/demande-op-commercial/demande-op-commercial.component';
import { ListCarteEnvoyerComponent } from './components/admin/list-carte-envoyer/list-carte-envoyer.component';
import { ListScanEffecterComponent } from './components/admin/list-scan-effecter/list-scan-effecter.component';
import { ResetPasswordComponent } from './components/home/reset-password/reset-password.component';
export const AppRoutes = [
{path: '', component: HomeComponent},
@ -31,8 +32,9 @@ export const AppRoutes = [
{path: 'debiterCarte/:idOp', component: DebiterCarteComponent, canActivate: [AuthGuard]},
{path: 'editProfil', component: EditProfilComponent, canActivate: [AuthGuard]},
{path: 'historiqueCarte', component: CarteEnvoyerComponent, canActivate: [AuthGuard]},
{path: 'listOpCommercialAdmin', component: ListeOpCommercialComponent},
{path: 'demandeOpCommercialAdmin', component: DemandeOpCommercialComponent},
{path: 'ListCarteEnvoyerAdmin/:idOp', component: ListCarteEnvoyerComponent},
{path: 'ListScanEffecterAdmin/:idOp', component: ListScanEffecterComponent}
{path: 'listOpCommercialAdmin', component: ListeOpCommercialComponent, canActivate: [AuthGuard]},
{path: 'demandeOpCommercialAdmin', component: DemandeOpCommercialComponent, canActivate: [AuthGuard]},
{path: 'ListCarteEnvoyerAdmin/:idOp', component: ListCarteEnvoyerComponent, canActivate: [AuthGuard]},
{path: 'ListScanEffecterAdmin/:idOp', component: ListScanEffecterComponent, canActivate: [AuthGuard]},
{path: 'ResetPassword', component: ResetPasswordComponent}
];

@ -53,7 +53,7 @@ export class DemandeOpCommercialComponent implements OnInit, OnDestroy {
.equalTo('En Cours')
.on('child_added', (child) => {
console.log('iiiii' + child);
this.toastrService.success("Nouvelle demande d'opération commerciale" );
this.toastrService.info("Nouvelle demande d'opération commerciale" );
});
@ -65,7 +65,6 @@ export class DemandeOpCommercialComponent implements OnInit, OnDestroy {
}
}).map((array) => array.reverse()) as FirebaseListObservable<any[]>;
}
console.log(auth.uid);
}
);
}

@ -105,7 +105,6 @@ export class ListeOpCommercialComponent implements OnInit, OnDestroy {
}
console.log(auth.uid);
}
);
}

@ -0,0 +1,31 @@
<div class="container">
<div class="card">
<div class="well">
<p class="h5 text-center mb-4">Réinitialiser mot de passe</p>
<!--<div> ID: {{ (user | async)?.uid }} </div>
<div> Email: {{ (user | async)?.email }} </div>-->
<div class="md-form">
<i class="fa fa-envelope prefix grey-text"></i>
<input type="email" [(ngModel)]="email" placeholder="Email" name="mail" required pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$" #mail="ngModel">
<div *ngIf="mail.errors && mail.errors.pattern && (mail.dirty || mail.touched)" class="alert alert-danger">
Votre <strong>email</strong> est requis et doit avoir ce format : <strong><i>john@gmail.fr</i></strong>.
</div>
</div>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-dark-green" [disabled]="mail.errors" (click)="resetPass()">Réinitialiser mot de passe<i class="fa fa-paper-plane-o ml-1"></i></button>
<!--<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>-->
<button class="btn btn-cyan" (click)="loadHomeComponent()">Retour</button>
</div>
<div *ngIf="emailExist" class="alert alert-danger">
Un <strong>email pour réinitiliser votre mot de passe</strong> vient de vous être envoyé à <strong><i>{{email}}</i></strong>.
</div>
<div *ngIf="emailExist == false" class="alert alert-danger">
L'email <strong><i>{{email}}</i></strong> n'est pas inscrit sur ParraineTesAmis.com
</div>
</div>
</div>
</div>

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

@ -0,0 +1,86 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import * as firebase from 'firebase/app';
import { AuthService } from '../../../services/auth/auth.service';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
@Component({
selector: 'app-reset-password',
templateUrl: './reset-password.component.html',
styleUrls: ['./reset-password.component.scss'],
providers: [AuthService]
})
export class ResetPasswordComponent implements OnInit, OnDestroy {
email: string;
emailExist: boolean;
profileDataParrainEmail: FirebaseListObservable<any[]>;
profileDataCommercantEmail: FirebaseListObservable<any[]>;
constructor(private router: Router, private afDb: AngularFireDatabase, private authService: AuthService) {
this.email = '';
}
/*
keyDownFunction(event) {
if(event.keyCode === 13) {
console.log('you just clicked enter');
// rest of your code
if (this.email !== ''){
this.resetPass();
}
}
}*/
resetPass() {
if (this.email !== '') {
console.log(this.emailExist);
this.verifEmail(this.email);
console.log(this.emailExist);
}
}
verifEmail(email: string){
let parrainExistPas = false;
let commercantExistPas = false;
this.profileDataParrainEmail = this.afDb.list('/Parrain/', {
query: {
orderByChild: 'email',
equalTo: email
}
}
);
this.profileDataParrainEmail.subscribe(snapshot => {
if (snapshot.length > 0) {
firebase.auth().sendPasswordResetEmail(email);
this.emailExist = true;
} else {
parrainExistPas = true;
}
});
this.profileDataCommercantEmail = this.afDb.list('/Commercant/', {
query: {
orderByChild: 'email',
equalTo: email
}
}
);
this.profileDataCommercantEmail.subscribe(snapshot => {
if (snapshot.length > 0) {
firebase.auth().sendPasswordResetEmail(email);
this.emailExist = true;
} else {
commercantExistPas = true;
if (parrainExistPas && commercantExistPas) {
this.emailExist = false;
}
}
});
}
loadHomeComponent() {
this.router.navigate(['/']);
}
ngOnInit() {
}
ngOnDestroy() {
this.email = '';
}
}

@ -23,9 +23,15 @@
<div class="text-center" style="margin-top:5%">
<button type="submit" class="btn btn-dark-green" [disabled]="mail.errors || pass.errors" (click)="login()">Se connecter<i class="fa fa-paper-plane-o ml-1"></i></button>
<!--<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>-->
</div>
<div class="text-center" style="margin-top:5%">
<a (click)="loadResetPasswordComponent()" class="blue-text">Mot de passe oublié ?</a>
</div>
<div *ngIf="echecLogin" class="alert alert-danger">
Erreur: votre <strong>email</strong> ou votre <strong>mot de passe n'est pas correct !</strong>.
</div>
</form>
</div>
</div>

@ -26,11 +26,12 @@ export class LoginComponent implements OnInit, OnDestroy {
myUser: User;
parrain: Parrain;
commercant: Commercant;
echecLogin: boolean;
user: Observable<firebase.User>;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService) {
this.echecLogin = false;
this.user = afAuth.authState;
this.email = '';
this.password = '';
@ -46,13 +47,21 @@ export class LoginComponent implements OnInit, OnDestroy {
}
}
login() {
this.authService.signIn(this.email, this.password);
try{
var tto = this.authService.signIn(this.email, this.password).catch(e => this.echecLogin = true);
console.log('iiiiiiiii' + tto);
}catch (e){
console.log('iiiiiiiii');
console.log(e);
}
}
loadHomeComponent() {
this.router.navigate(['/']);
}
loadResetPasswordComponent() {
this.router.navigate(['/ResetPassword']);
}
loadRegisterComponent() {
this.router.navigate(['/register']);
}

@ -114,6 +114,9 @@
<div *ngIf="carteEnvoieOK" class="alert alert-danger">
Une carte vient d'être envoyée au nouveau Parrain {{cartePar.parrainCarte.firstname}} {{cartePar.parrainCarte.familyname}}
</div>
<div *ngIf="echecRegisterPar" class="alert alert-danger">
Erreur: Un compte avec cet <strong>email</strong> existe déjà.
</div>
</div>
</div>
</div>

@ -70,7 +70,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
carteExitDeja: boolean;
carteEnvoieOK: boolean;
carteEnvoieEncours: boolean;
echecRegisterPar: boolean;
cartePars: any;
filteredCartePars: any;
@ -82,6 +82,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.user = afAuth.authState;
this.carteExitDeja = false;
this.carteEnvoieOK = false;
this.echecRegisterPar = false;
this.carteEnvoieEncours = false;
this.filteredCartePars = {};
this.radioParrain = '';
@ -251,71 +252,92 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.parrain.password = this.getRandomArbitrary(111111, 999999).toString();
// this.authService.signUp(this.parrain);
parrainTemp = this.parrain;
this.secondaryApp.auth().createUserWithEmailAndPassword(parrainTemp.email, parrainTemp.password).then(function(userCreate) {
console.log('User ' + userCreate.uid + ' created successfully!');
// I don't know if the next statement is necessary
const imagePath = 'profilImage/' + userCreate.uid + '/userPic.jpg';
const dbRef = firebase.database().ref();
const userRef = dbRef.child('Parrain').child(userCreate.uid);
userCreate.updateProfile({
displayName: parrainTemp.status,
photoURL: imagePath,
emailVerified: true
});
try {
parrainTemp.uid = userCreate.uid;
parrainTemp.emailVerified = userCreate.emailVerified;
userRef.set(parrainTemp);
console.log('crer par: ' + parrainTemp.firstname);
// this.cartePar.parrainCarte = parrainTemp;
var ilExist = false;
var parrainExistListTemp = this.afDb.list('/Parrain/', {
query: {
orderByChild: 'email',
equalTo: this.parrain.email
}
}
).subscribe(tab => {
if (tab.length === 0) {
console.log('iiii');
this.secondaryApp.auth().createUserWithEmailAndPassword(parrainTemp.email, parrainTemp.password)
.catch(e => {
console.log('lololo ' + e);
this.carteEnvoieOK = false;
})
.then(function(userCreate) {
console.log('User ' + userCreate.uid + ' created successfully!');
// I don't know if the next statement is necessary
const imagePath = 'profilImage/' + userCreate.uid + '/userPic.jpg';
const dbRef = firebase.database().ref();
const userRef = dbRef.child('Parrain').child(userCreate.uid);
userCreate.updateProfile({
displayName: parrainTemp.status,
photoURL: imagePath,
emailVerified: true
});
try {
parrainTemp.uid = userCreate.uid;
parrainTemp.emailVerified = userCreate.emailVerified;
userRef.set(parrainTemp);
console.log('crer par: ' + parrainTemp.firstname);
// this.cartePar.parrainCarte = parrainTemp;
this.secondaryApp.auth().sendPasswordResetEmail(userCreate.email);
userCreate.sendEmailVerification();
console.log('avant logout firebase.auth().currentUser.uid: ');
this.secondaryApp.auth().signOut();
console.log('avant logout firebase.auth().currentUser.uid: ');
this.secondaryApp.auth().sendPasswordResetEmail(userCreate.email);
userCreate.sendEmailVerification();
} catch (e) {
// No content response..
console.log('error dans envoyer carte !');
console.log(e);
// this.goToOpComm();
// this.router.navigate(['/']);
}
//fin
// this.secondaryApp.auth().signOut();
});
console.log('avant logout firebase.auth().currentUser.uid: ');
this.secondaryApp.auth().signOut();
console.log('avant logout firebase.auth().currentUser.uid: ');
} catch (e) {
// No content response..
console.log('error dans envoyer carte !');
console.log(e);
// this.goToOpComm();
// this.router.navigate(['/']);
}
//fin
// this.secondaryApp.auth().signOut();
});
const parNewlistTemp = this.afDb.list('/Parrain/', {
query: {
orderByChild: 'email',
equalTo: parrainTemp.email
}
}
);
parNewlistTemp.forEach(par => {
par.forEach(elementParTemp => {
if (elementParTemp !== undefined) {
if (elementParTemp.uid !== '') {
this.getIdParrain(elementParTemp.uid);
this.creerCartePar();
this.carteEnvoieEncours = true;
this.carteEnvoieOK = true;
setTimeout(() => {
this.carteEnvoieEncours = false;
this.goToOpComm();
this.toastrService.success('Envoie de la carte à ' + elementParTemp.familyname
+ ' ' + elementParTemp.firstname);
},
3000);
const parNewlistTemp = this.afDb.list('/Parrain/', {
query: {
orderByChild: 'email',
equalTo: parrainTemp.email
}
}
}
});
);
parNewlistTemp.forEach(par => {
par.forEach(elementParTemp => {
if (elementParTemp !== undefined) {
if (elementParTemp.uid !== '') {
this.getIdParrain(elementParTemp.uid);
this.creerCartePar();
this.carteEnvoieEncours = true;
this.carteEnvoieOK = true;
setTimeout(() => {
this.carteEnvoieEncours = false;
this.goToOpComm();
this.toastrService.success('Envoie de la carte à ' + elementParTemp.familyname
+ ' ' + elementParTemp.firstname);
},
3000);
}
}
});
});
} else {
this.echecRegisterPar = true;
console.log('il est la');
}
});
}
@ -378,8 +400,11 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
getRandomArbitrary(min, max) {
return Math.trunc(Math.random() * (max - min) + min);
}
initParSelect(){
initParSelect() {
this.parSelect = '';
this.parrain = new Parrain;
this.birthdayTemp = new Date;
this.echecRegisterPar = false;
}
getIdParrain(parUid) {

@ -92,7 +92,10 @@
<div class="text-center" style="margin-top:5%">
<button class="btn btn-deep-orange" [disabled]="filePar || !birthday.touched || (birthday.touched && validationBirthdayParrain()) || email.errors || password.errors || (parrain.password != ConfirmPasswordParrain) || parrain.familyname == '' || parrain.firstname == '' || parrain.sex == '' || test" (click)="register()">S'inscrire</button>
<!--<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>-->
<div *ngIf="test" class="alert alert-danger">
<div *ngIf="echecRegisterPar" class="alert alert-danger">
Erreur: Un compte avec cet <strong>email</strong> existe déjà.
</div>
<div *ngIf="(echecRegisterCom !== true) && test" class="alert alert-danger">
<strong><i>{{parrain.familyname}} {{parrain.firstname}}, </i></strong> votre compte à bien été créé, un email de validation vient de vous être envoyé à l'adresse <strong><i>{{parrain.email}}</i></strong> !
</div>
</div>
@ -156,7 +159,10 @@
<div class="text-center" style="margin-top:5%">
<button class="btn btn-deep-orange" [disabled]="fileCom || email.errors || password.errors || siret.errors || commercant.raisonSociale == '' || commercant.commercialName == '' || (commercant.password != ConfirmPasswordCommercant) || test" (click)="register()">S'inscrire</button>
<!--<button class="btn btn-cyan" (click)="loadHomeComponent()">Back</button>-->
<div *ngIf="test" class="alert alert-danger">
<div *ngIf="echecRegisterCom" class="alert alert-danger">
Erreur: Un compte avec cet <strong>email</strong> existe déjà.
</div>
<div *ngIf="test && (echecRegisterCom !== true)" class="alert alert-danger">
<strong><i>{{commercant.commercialName}}, </i></strong> votre compte à bien été créé, un email de validation vient de vous être envoyé à l'adresse <strong><i>{{commercant.email}}</i></strong> !
</div>
</div>

@ -26,11 +26,14 @@ export class RegisterComponent implements OnInit, OnDestroy {
parrainDateTimeTest: Date;
fileCom: boolean;
filePar: boolean;
echecRegisterPar: boolean;
echecRegisterCom: boolean;
constructor(private router: Router, private authService: AuthService) {
// this.fileTest = new File();
this.fileCom = true;
this.filePar = true;
this.echecRegisterPar = false;
this.echecRegisterCom = false;
this.currentUser = new User();
this.parrain = new Parrain();
this.commercant = new Commercant();
@ -83,19 +86,27 @@ export class RegisterComponent implements OnInit, OnDestroy {
if (this.currentUser.status === 'Parrain') {
this.parrain.status = this.currentUser.status;
this.parrain.secretCode = this.getRandomArbitrary(1111, 9999).toString();
this.authService.signUp(this.parrain);
this.authService.signUp(this.parrain).catch(e => {
this.echecRegisterPar = true;
this.test = false;
});
/*if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
this.clean();
}*/
this.echecRegisterPar = false;
this.test = true;
}else if (this.currentUser.status === 'Commercant') {
this.commercant.status = this.currentUser.status;
let dateTemp = new Date(Date.now());
this.commercant.dateInscription = new Date(dateTemp);
this.authService.signUp(this.commercant);
this.authService.signUp(this.commercant).catch(e => {
this.echecRegisterCom = true;
this.test = false;
});
/*if ((<HTMLInputElement>document.getElementById('orangeForm-File')).value !== '') {
this.clean();
}*/
this.echecRegisterCom = false;
this.test = true;
}
}

@ -37,6 +37,8 @@ export class AuthService {
profileData: FirebaseListObservable<any[]>;
profileDataParrain: FirebaseListObservable<any[]>;
profileDataCommercant: FirebaseListObservable<any[]>;
profileDataParrainEmail: FirebaseListObservable<any[]>;
profileDataCommercantEmail: FirebaseListObservable<any[]>;
boolUpdate: boolean;
boolSetData: boolean;
@ -97,9 +99,16 @@ export class AuthService {
});
}
// oublie pas de MAJ emailVerified dans database
signIn(email: string, password: string) {
firebase.auth().signInWithEmailAndPassword(email, password).then(user => {
return firebase.auth().signInWithEmailAndPassword(email, password)
.catch(e => {
console.log('lololo ' + e);
return e;
})
.then(user => {
if (user) {
this.profileDataParrain = this.afDb.list('/Parrain/', {
@ -213,7 +222,11 @@ export class AuthService {
}
*/
signUp(infoUser: any) {
firebase.auth().createUserWithEmailAndPassword(infoUser.email, infoUser.password)
return firebase.auth().createUserWithEmailAndPassword(infoUser.email, infoUser.password)
.catch(e => {
console.log('lololo ' + e);
return e;
})
.then(userCreate => {
userCreate.sendEmailVerification().then(res => {
console.log('res : ');
@ -231,7 +244,7 @@ export class AuthService {
console.log('save info failed !!! ');
}
})
});
}

Loading…
Cancel
Save