MAJ login component profil et ajout de nouveau modele
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,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}
|
||||
];
|
||||
|
@ -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…
Reference in New Issue