MAJ login component profil et ajout de nouveau modele

thierry
Tmadkaud 7 years ago
parent 6b0055220d
commit a6bf76a6df

@ -0,0 +1,51 @@
//nouvelle operation commercial / nouvelle carte
export class CarteParrainage
{
uid: string;
avantageParrain: string;
avantageFilleul: string;
avantageCumule: string;
avantageRecuperer: string;
avantageXJC: string;
commercantID: string;
parrainID: string;
carteTemplate: string;
carteId: string;
status: string;
dateDebut: Date;
dateFin: Date;
constructor() {
this.uid = '';
this.avantageParrain = '';
this.avantageFilleul = '';
this.avantageCumule = '';
this.avantageRecuperer = '';
this.avantageXJC = '';
this.commercantID = '';
this.parrainID = '';
this.carteTemplate = '';
this.carteId = '';
this.status = '';
this.dateDebut = new Date();
this.dateFin = new Date();
}
/*
addParrain(addStatus, addEmail, addFamilyname, addFirstname) {
this.uid = '';
this.email = addEmail;
this.emailVerified = false;
this.password = '';
this.familyname = addFamilyname;
this.firstname = addFirstname;
this.username = '';
this.birthday = new Date();
this.idCard = '';
this.secretCode = '';
this.status = addStatus;
}
welcome() {
console.log('Hi, ' + this.firstname + '!');
}
*/
}

@ -1,9 +1,9 @@
export class User
{
_id: string;
uid: string;
email: string;
emailVerified: boolean;
password: string;
password:string;
familyname: string;
firstname: string;
username: string;
@ -11,4 +11,36 @@ export class User
idCard: string;
secretCode: string;
status: string;
constructor() {
//sexe
this.uid = '';
this.email = '';
this.emailVerified = false;
this.password = '';
this.familyname = '';
this.firstname = '';
this.username = '';
this.birthday = new Date();
this.idCard = '';
this.secretCode = '';
this.status = '';
}
/*
addParrain(addStatus, addEmail, addFamilyname, addFirstname) {
this.uid = '';
this.email = addEmail;
this.emailVerified = false;
this.password = '';
this.familyname = addFamilyname;
this.firstname = addFirstname;
this.username = '';
this.birthday = new Date();
this.idCard = '';
this.secretCode = '';
this.status = addStatus;
}
welcome() {
console.log('Hi, ' + this.firstname + '!');
}
*/
}

@ -19,6 +19,7 @@ import { HomeComponent } from './components/home/home.component';
import { LoginComponent } from './components/login/login.component';
import { RegisterComponent } from './components/register/register.component';
import { NavigationBarComponent } from './components/navigationBar/navigationBar.component';
import { ProfilComponent } from './components/profil/profil.component';
@NgModule({
@ -27,7 +28,8 @@ import { NavigationBarComponent } from './components/navigationBar/navigationBar
HomeComponent,
NavigationBarComponent,
LoginComponent,
RegisterComponent
RegisterComponent,
ProfilComponent
],
imports: [
BrowserModule,

@ -1,9 +1,11 @@
import { LoginComponent } from './components/login/login.component';
import { RegisterComponent } from './components/register/register.component';
import { HomeComponent } from './components/home/home.component';
import { ProfilComponent } from './components/profil/profil.component';
export const AppRoutes = [
{path: '', component: HomeComponent},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent}
{path: 'register', component: RegisterComponent},
{path: 'profil', component: ProfilComponent}
];

@ -1,7 +1,21 @@
<p>
Register
</p>
<p>
Créer un compte
(c'est gratuit !)
</p>
<form class="form-inline">
<div class="form-group">
<input name="group2" type="radio" class="with-gap" id="homme">
<label for="homme">Homme</label>
</div>
<div class="form-group">
<input name="group2" type="radio" class="with-gap" id="femme">
<label for="femme">Femme</label>
</div>
</form>
<div class="from-group">
<input [(ngModel)]="currentUser.familyname" placeholder="Family name..">
</div>
@ -20,6 +34,35 @@
<div class="from-group">
<input type="password" [(ngModel)]="currentUser.password" placeholder="Password..">
</div>
Etes-vous:
<!--
<div class="form-group">
<input name="client" type="radio" class="with-gap" id="client">
<label for="client">Client</label>
</div>
<div class="form-group">
<input name="commercant" type="radio" class="with-gap" id="commercant">
<label for="commercant">Commercant</label>
</div>
-->
<form class="form-inline">
<div class="form-group">
<input name="group2" type="radio" class="with-gap" id="client">
<label for="client">Client</label>
</div>
<div class="form-group">
<input name="group2" type="radio" class="with-gap" id="commercant">
<label for="commercant">Commercant</label>
</div>
</form>
<p>
En cliquant sur Créer un compte, vous acceptez nos Conditions
et indiquez que vous aves lu notre Politique d'utilisation des
données, y compris notre Utilisation des cookies.
</p>
<button (click)="register()">Register</button>
<button (click)="loadLoginComponent()">Go to login</button>
<button (click)="loadHomeComponent()">Go to home</button>

@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [AuthService]
});
});
it('should ...', inject([AuthService], (service: AuthService) => {
expect(service).toBeTruthy();
}));
});

@ -0,0 +1,76 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule, Headers } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { User } from '../../../User';
@Injectable()
export class AuthService {
databaseRef: any;
changeRequest: any;
userModel: User;
constructor(private http: HttpModule, public afAuth: AngularFireAuth, public afDb: AngularFireDatabase, public router: Router) {
this.databaseRef = firebase.database().ref();
}
saveInfo(currentUser: User, user: firebase.User){
const userRef = this.databaseRef.child('users').child(user.uid);
var userInfo = currentUser;
userInfo.uid = user.uid;
userInfo.email = user.email;
userInfo.emailVerified = user.emailVerified;
userRef.set(userInfo);
this.router.navigate(['/login']);
}
signIn(email: string, password: string) {
firebase.auth().signInWithEmailAndPassword(email, password).then(user =>{
if (user) {
console.log('salut ' + user.displayName + ' has signed!');
this.router.navigate(['/profil']);
}else {
console.log('error!!');
}
});
}
setUserInfo(currentUser: User, user: firebase.User) {
const imagePath = 'profilImage/!' + user.uid + '/userPic.jpg';
firebase.auth().onAuthStateChanged(function (userUpdate) {
userUpdate.updateProfile({
displayName: currentUser.username,
photoURL: imagePath
});
if (userUpdate) {
console.log('userUpdate: ' + userUpdate);
} else {
console.log('pas user');
}
});
this.saveInfo(currentUser, user);
}
signUp(currentUser: User) {
firebase.auth().createUserWithEmailAndPassword(currentUser.email, currentUser.password).then(userCreate => {
this.setUserInfo(currentUser, userCreate);
});
}
logout() {
firebase.auth().signOut();
}
}

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

@ -0,0 +1,8 @@
import { Injectable } from '@angular/core';
@Injectable()
export class ProfilService {
constructor() { }
}
Loading…
Cancel
Save