Commit 871ebe8c by Nabil Sadki

Optimise params && anonymous mode

parent ab4d459e
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="11000" id="com.allotesteurs.app" version="1.1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="11000" id="com.allotesteurs.app" version="1.1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Allo Testeurs</name>
<description>Découvrir les bon plans à Kénitra et ailleurs!</description>
<author email="contact@allo-testeurs.com" href="https://www.allo-testeurs.com">Allo Testeurs Agency</author>
<content src="index.html" />
<access origin="*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-navigation href="http://*/*" />
......
......@@ -15,6 +15,7 @@
"dependencies": {
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2",
......@@ -47,11 +48,13 @@
"cordova-sqlite-storage": "^3.2.0",
"cordova.plugins.diagnostic": "^5.0.0",
"core-js": "^2.5.4",
"firebase": "^6.6.1",
"ionic-image-loader": "^6.3.3",
"leaflet": "^1.5.1",
"leaflet.markercluster": "^1.4.1",
"path": "^0.12.7",
"rxjs": "~6.5.1",
"sweetalert": "^2.1.2",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
},
......
......@@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{ path: '', redirectTo: 'start', pathMatch: 'full' },
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'start', loadChildren: './pages/start/start.module#StartPageModule' },
{ path: 'login', loadChildren: './pages/compte/login/login.module#LoginPageModule' },
{ path: 'mainslider', loadChildren: './pages/mainslider/mainslider.module#MainsliderPageModule' },
......
......@@ -46,7 +46,8 @@ export class AppComponent {
this._STOR.get('wpUser').then((wpUser) => {
if (wpUser) {
this._AUTH.validateAuthToken(wpUser.token);
this.router.navigateByUrl('/app/dashboard', { replaceUrl: true });
// this._AUTH.validateAuthToken(wpUser.token);
} else {
this.router.navigateByUrl('/login', { replaceUrl: true });
}
......@@ -69,34 +70,16 @@ export class AppComponent {
}
setDefaultParams() {
this._STOR.get('PARAM_geolocate').then((val) => {
this._STOR.get('APP_PARAMS').then((val) => {
if (val === null) {
this._STOR.set('PARAM_geolocate', true);
}
});
this._STOR.get('PARAM_geoarea').then((val) => {
if (val === null) {
this._STOR.set('PARAM_geoarea', 1000);
}
});
this._STOR.get('PARAM_notiftime').then((val) => {
if (val === null) {
this._STOR.set('PARAM_notiftime', 2880);
}
});
this._STOR.get('PARAM_trackdelay').then((val) => {
if (val === null) {
this._STOR.set('PARAM_trackdelay', 60000);
}
});
this._STOR.get('PARAM_notifnbr').then((val) => {
if (val === null) {
this._STOR.set('PARAM_notifnbr', 'all');
}
});
this._STOR.get('NOTIF_shownpartners').then((val) => {
if (val === null) {
this._STOR.set('NOTIF_shownpartners', []);
this._STOR.set('APP_PARAMS', {
PARAM_geolocate: true,
PARAM_geoarea: 1000,
PARAM_notiftime: 2880,
PARAM_trackdelay: 60000,
PARAM_notifnbr: 'all',
NOTIF_shownpartners: [],
});
}
});
}
......
......@@ -19,6 +19,13 @@ import { BackgroundMode } from '@ionic-native/background-mode/ngx';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { AppVersion } from '@ionic-native/app-version/ngx';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { environment } from 'src/environments/environment';
import { AuthService } from './services/auth.service';
import { AngularFireAuthModule } from '@angular/fire/auth';
// import * as firebase from 'firebase';
// firebase.initializeApp(environment.firebase);
@NgModule({
declarations: [AppComponent],
......@@ -31,7 +38,8 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx';
name: '__allo_testeurs_app',
driverOrder: ['websql', 'sqlite', 'indexeddb']
}),
HttpClientModule
HttpClientModule,
AngularFireAuthModule
],
providers: [
StatusBar,
......@@ -44,7 +52,8 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx';
BackgroundMode,
BackgroundGeolocation,
AppVersion,
GooglePlus
GooglePlus,
AuthService
],
bootstrap: [AppComponent]
})
......
......@@ -59,18 +59,26 @@
</div>
</ion-card-content>
</ion-card>
<a href="javascript:;">
<!-- <a href="javascript:;">
<ion-text color="light">
Mot de passe oublié?
</ion-text>
</a>
</a> -->
<ion-item-divider color="primary"> </ion-item-divider>
<ion-button color="dark" expand="block" type="submit" [disabled]="validationsForm.invalid" no-margin>Connexion</ion-button>
<ion-button color="dark" expand="block" type="submit" [disabled]="validationsForm.invalid" no-margin>
<ion-icon name="log-in"></ion-icon>
Connexion
</ion-button>
</form>
<ion-item-divider color="primary" lines="none"> </ion-item-divider>
<ion-item-divider color="primary" justify-content-center>
<!-- <ion-item-divider color="primary" justify-content-center>
Se connecter avec Facebook ou Google
</ion-item-divider>
</ion-item-divider> -->
<ion-button color="light" expand="block" class="btn-g" (click)="doAnonymousLogIn()" no-margin>
<ion-icon name="walk"></ion-icon>
Connexion anonyme
</ion-button>
<ion-grid>
<ion-row>
<!-- <ion-col>
......@@ -79,9 +87,9 @@
</ion-button>
</ion-col> -->
<ion-col>
<ion-button color="light" expand="block" class="btn-g" (click)="doGoogleLogin()" no-margin>
<!-- <ion-button color="light" expand="block" class="btn-g" (click)="doGoogleLogin()" no-margin>
<ion-icon name="logo-google"></ion-icon>
</ion-button>
</ion-button> -->
</ion-col>
</ion-row>
</ion-grid>
......
......@@ -5,6 +5,7 @@ import { AuthService } from '../../../services/auth.service';
import { Storage } from '@ionic/storage';
import { Router } from '@angular/router';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
// import swal from 'sweetalert';
@Component({
selector: 'app-login',
......@@ -47,9 +48,44 @@ export class LoginPage implements OnInit {
});
}
doAnonymousLogIn() {
this.storage.set('wpUser', {
token: null,
user_nicename: 'anonymous',
user_display_name: 'Mode anonyme',
user_email: 'nomail',
});
this.router.navigateByUrl('/mainslider', { replaceUrl: true });
}
onSubmit(values) {
console.log(values);
this._AUTH.doLogin(values.email, values.password);
this._ALLO.presentLoading();
this._AUTH.doLogin(values)
.then(
res => {
this._ALLO.dismissLoading();
console.log('User exist', res);
this.router.navigateByUrl('/mainslider', { replaceUrl: true });
},
err => {
this._ALLO.dismissLoading();
// swal('Connexion', 'Email ou Mot de passe incorrects. Veuillez réessayer.', 'error');
// this._ALLO.presentAlert('Connexion', 'Email ou Mot de passe incorrects.<br>Veuillez réessayer.');
this._ALLO.presentToast('', 'Email ou Mot de passe incorrects.<br>Veuillez réessayer.', 'top');
console.log('Auth error', err);
});
// this._ALLO.presentLoading();
// this._AUTH.firebaseRegister(values)
// .then(res => {
// this._ALLO.dismissLoading();
// console.log('User exist', res);
// // this.errorMessage = "";
// // this.navCtrl.navigateForward('/dashboard');
// }, err => {
// this._ALLO.dismissLoading();
// // this.errorMessage = err.message;
// console.log('Auth error', err);
// });
}
async doGoogleLogin() {
......
......@@ -10,7 +10,7 @@
</ion-col>
<ion-col size="8">
<ion-text>
<h4>Nabil Sadki</h4>
<h4>{{ _AUTH.infoFullname }}</h4>
</ion-text>
<ion-chip color="light" outline="true">
<ion-icon name="star"></ion-icon>
......@@ -49,7 +49,7 @@
</ion-menu-toggle>
</ion-col>
<ion-col no-padding class="column">
<ion-button size="small" color="dark" href="/login">
<ion-button size="small" color="dark" (click)="logout()">
<ion-icon name="log-out"></ion-icon>
Déconnexion
</ion-button>
......
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../../services/auth.service';
@Component({
selector: 'app-menu',
......@@ -40,7 +42,15 @@ export class MenuPage implements OnInit {
}
];
constructor() { }
constructor(
public router: Router,
public _AUTH: AuthService
) { }
logout() {
this._AUTH.logOut();
this.router.navigateByUrl('/login', { replaceUrl: true });
}
ngOnInit() {
// this._ALLO.presentLoading();
......
......@@ -31,7 +31,7 @@ export class OffresCartePage implements OnInit {
if (loadedData) {
this._TRIP.offersCardListPointer = this._TRIP.offersCardListPointer + 1;
this._TRIP.offersCardList = this._TRIP.offersCardList.concat(loadedData);
console.log(loadedData, this._TRIP.offersCardList, this._TRIP.offersCardListPointer);
// console.log(loadedData, this._TRIP.offersCardList, this._TRIP.offersCardListPointer);
event.target.complete();
} else {
event.target.disabled = true;
......
<ion-content>
<ion-list-header>Meilleures deals</ion-list-header>
<ion-content padding>
<ion-card color="light" margin-bottom>
<ion-text class="ion-text-center">
<img class="soon" src="../../../../assets/img/soon.png">
</ion-text>
</ion-card>
<ion-text class="ion-text-justify">
<p>
Que vous soyez détenteur(se) ou non de la Carte Testeur, cette section est ouverte à tout le monde, et permettra
dans un future proche de bénéficier des offres de nos partenaires.
</p>
<p>
Les plus fidéles seront <strong color="primary">trop bien</strong> récompensés!!
</p>
<p>
Restez à l'écoute!
</p>
</ion-text>
<!-- <ion-list-header>Meilleures deals</ion-list-header>
<div class="app">
<ul class="hs">
<li class="item">test</li>
......@@ -14,5 +31,5 @@
<ion-item>
Offre
</ion-item>
</ion-list>
</ion-list> -->
</ion-content>
\ No newline at end of file
......@@ -57,3 +57,9 @@ ul {
background: #fff;
border-radius: 8px;
}
img.soon {
height: 30vh !important;
width: auto !important;
margin: 0 auto;
}
\ No newline at end of file
......@@ -13,64 +13,40 @@
<form class="list-form">
<!-- <ion-item>
<ion-label color="dark" class="text-1x">Cacher l'écran d'accueil</ion-label>
<ion-toggle checked color="primary" [(ngModel)]="prm_mainslider" [ngModelOptions]="{standalone: true}"
<ion-toggle checked color="primary" [(ngModel)]="prmMainslider" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('mainslider')"></ion-toggle>
</ion-item> -->
<ion-item>
<ion-label color="dark" class="text-1x">Géo-notifications</ion-label>
<ion-toggle checked color="primary" [(ngModel)]="prm_geolocate" [ngModelOptions]="{standalone: true}"
<ion-toggle color="primary" [(ngModel)]="prmGeolocate" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('geolocate')"></ion-toggle>
</ion-item>
<ion-item>
<ion-label color="dark" class="text-1x">Rayon de détection</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_geoarea" [ngModelOptions]="{standalone: true}"
<ion-select class="text-primary" [(ngModel)]="prmGeoarea" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('geoarea')">
<ion-select-option value="400">400m</ion-select-option>
<ion-select-option value="800">800m</ion-select-option>
<ion-select-option value="1200">1,2Km</ion-select-option>
<ion-select-option value="1600">1,6Km</ion-select-option>
<ion-select-option value="2000">2Km</ion-select-option>
<ion-select-option *ngFor="let gOpt of geoAreaOptions | keyvalue" [value]="gOpt.key">{{ gOpt.value }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label color="dark" class="text-1x">Raffraichir la position GPS chaque</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_trackdelay" [ngModelOptions]="{standalone: true}"
<ion-select class="text-primary" [(ngModel)]="prmTrackdelay" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('trackdelay')">
<ion-select-option value="60000">minute</ion-select-option>
<ion-select-option value="120000">2 minutes</ion-select-option>
<ion-select-option value="180000">3 minutes</ion-select-option>
<ion-select-option value="240000">4 minutes</ion-select-option>
<ion-select-option value="300000">5 minutes</ion-select-option>
<ion-select-option value="360000">6 minutes</ion-select-option>
<ion-select-option value="420000">7 minutes</ion-select-option>
<ion-select-option value="480000">8 minutes</ion-select-option>
<ion-select-option value="540000">9 minutes</ion-select-option>
<ion-select-option value="600000">10 minutes</ion-select-option>
<ion-select-option *ngFor="let tdOpt of trackDelayOptions | keyvalue" [value]="tdOpt.key">{{ tdOpt.value }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label color="dark" class="text-1x">Réaffichage des notifications</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_notiftime" [ngModelOptions]="{standalone: true}"
<ion-select class="text-primary" [(ngModel)]="prmNotiftime" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('notiftime')">
<ion-select-option value="5">5 min</ion-select-option>
<ion-select-option value="15">15 min</ion-select-option>
<ion-select-option value="30">30 min</ion-select-option>
<ion-select-option value="45">45 min</ion-select-option>
<ion-select-option value="60">1 h</ion-select-option>
<ion-select-option value="120">2 h</ion-select-option>
<ion-select-option value="480">4 h</ion-select-option>
<ion-select-option value="960">8 h</ion-select-option>
<ion-select-option value="2880">1 j</ion-select-option>
<ion-select-option *ngFor="let ntOpt of notifTimeOptions | keyvalue" [value]="ntOpt.key">{{ ntOpt.value }}</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label color="dark" class="text-1x">Notifications par rafraîchissement</ion-label>
<ion-select class="text-primary" [(ngModel)]="prm_notifnbr" [ngModelOptions]="{standalone: true}"
<ion-select class="text-primary" [(ngModel)]="prmNotifnbr" [ngModelOptions]="{standalone: true}"
(ionChange)="setParam('notifnbr')">
<ion-select-option value="2">Pas plus de 2 à la fois</ion-select-option>
<ion-select-option value="4">Pas plus de 4 à la fois</ion-select-option>
<ion-select-option value="6">Pas plus de 6 à la fois</ion-select-option>
<ion-select-option value="all">Afficher toutes les notifications</ion-select-option>
<ion-select-option *ngFor="let nnOpt of notifNbrOptions | keyvalue" [value]="nnOpt.key">{{ nnOpt.value }}</ion-select-option>
</ion-select>
</ion-item>
</form>
......
......@@ -11,12 +11,49 @@ import { AlloService } from '../../services/allo-service';
})
export class ParamsPage implements OnInit {
public prm_mainslider = true;
public prm_geolocate = false;
public prm_geoarea: any = 400;
public prm_notiftime = 15;
public prm_trackdelay = 60000;
public prm_notifnbr: any = 'all';
public prmMainslider = true;
public prmGeolocate = false;
public prmGeoarea: any = 400;
public prmNotiftime = 15;
public prmTrackdelay = 60000;
public prmNotifnbr: any = 'all';
public geoAreaOptions = {
400: '400m',
800: '800m',
1200: '1,2Km',
1600: '1,6m',
2000: '2Km',
};
public trackDelayOptions = {
60000: '1 minute',
120000: '2 minutes',
180000: '3 minutes',
240000: '4 minutes',
300000: '5 minutes',
360000: '6 minutes',
420000: '7 minutes',
480000: '8 minutes',
540000: '9 minutes',
600000: '10 minutes',
};
public notifTimeOptions = {
5: '5 minutes',
15: '15 minutes',
30: '30 minutes',
45: '45 minutes',
60: '1 heure',
120: '2 heure',
480: '4 heure',
960: '8 heure',
2880: '1 jour',
};
public notifNbrOptions = {
2: 'Pas plus de 2 à la fois',
4: 'Pas plus de 4 à la fois',
6: 'Pas plus de 6 à la fois',
all: 'Afficher toutes les notifications',
};
constructor(
private _STOR: Storage,
......@@ -24,66 +61,50 @@ export class ParamsPage implements OnInit {
private _LOCAT: LocationService,
private _ALLO: AlloService
) {
this._STOR.get('PARAM_mainslider').then((val) => {
if (val !== null) {
this.prm_mainslider = val;
}
});
this._STOR.get('PARAM_geolocate').then((val) => {
if (val !== null) {
this.prm_geolocate = val;
}
});
this._STOR.get('PARAM_geoarea').then((val) => {
if (val !== null) {
this.prm_geoarea = val;
}
});
this._STOR.get('PARAM_notiftime').then((val) => {
if (val !== null) {
this.prm_notiftime = val;
}
});
this._STOR.get('PARAM_trackdelay').then((val) => {
if (val !== null) {
this.prm_trackdelay = val;
}
});
this._STOR.get('PARAM_notifnbr').then((val) => {
if (val !== null) {
this.prm_notifnbr = val;
this._STOR.get('APP_PARAMS').then((appParams) => {
if (appParams !== null) {
this.prmGeolocate = appParams.PARAM_geolocate;
this.prmGeoarea = appParams.PARAM_geoarea;
this.prmNotiftime = appParams.PARAM_notiftime;
this.prmTrackdelay = appParams.PARAM_trackdelay;
this.prmNotifnbr = appParams.PARAM_notifnbr;
}
});
}
setParam(name) {
switch (name) {
case 'mainslider':
this._ALLO.setParam('mainslider', this.prm_mainslider);
break;
case 'geolocate':
this._ALLO.setParam('geolocate', this.prm_geolocate);
if (this.prm_geolocate) {
this._PERM.checkGps();
this._LOCAT.initLocator();
} else {
this._LOCAT.stopLocator();
this._STOR.get('APP_PARAMS').then((appParams) => {
if (appParams !== null) {
switch (name) {
// case 'mainslider':
// this._ALLO.setParam('mainslider', this.prm_mainslider);
// break;
case 'geolocate':
appParams.PARAM_geolocate = this.prmGeolocate;
if (this.prmGeolocate) {
this._PERM.checkGps();
this._LOCAT.initLocator();
} else {
this._LOCAT.stopLocator();
}
break;
case 'geoarea':
appParams.PARAM_geoarea = +this.prmGeoarea;
break;
case 'notiftime':
appParams.PARAM_notiftime = +this.prmNotiftime;
break;
case 'notifnbr':
appParams.PARAM_notifnbr = +this.prmNotifnbr;
break;
case 'trackdelay':
appParams.PARAM_trackdelay = +this.prmTrackdelay;
this._LOCAT.restartTracking();
break;
}
break;
case 'geoarea':
this._ALLO.setParam('geoarea', +this.prm_geoarea);
break;
case 'notiftime':
this._ALLO.setParam('notiftime', +this.prm_notiftime);
break;
case 'notifnbr':
this._ALLO.setParam('notifnbr', +this.prm_notifnbr);
break;
case 'trackdelay':
this._ALLO.setParam('trackdelay', +this.prm_trackdelay);
this._LOCAT.restartTracking();
break;
}
this._STOR.set('APP_PARAMS', appParams);
}
});
}
ngOnInit() {
......
import { LoadingController, AlertController } from "@ionic/angular";
import { Injectable } from "@angular/core";
import { LoadingController, AlertController, ToastController } from '@ionic/angular';
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
@Injectable({ providedIn: 'root' })
......@@ -12,44 +12,25 @@ export class AlloService {
public prmNotiftime = 15;
public prmTrackdelay = 60000;
public prmNotifnbr: any = 'all';
public loading;
constructor(
private alertCtrl: AlertController,
private loadingCtrl: LoadingController,
private toastCtrl: ToastController,
private _STOR: Storage
) {
this.setDefaultParams();
}
setDefaultParams() {
this._STOR.get('PARAM_mainslider').then((val) => {
if (val !== null) {
this.prmMainslider = val;
}
});
this._STOR.get('PARAM_geolocate').then((val) => {
if (val !== null) {
this.prmGeolocate = val;
}
});
this._STOR.get('PARAM_geoarea').then((val) => {
if (val !== null) {
this.prmGeoarea = val;
}
});
this._STOR.get('PARAM_notiftime').then((val) => {
if (val !== null) {
this.prmNotiftime = val;
}
});
this._STOR.get('PARAM_trackdelay').then((val) => {
if (val !== null) {
this.prmTrackdelay = val;
}
});
this._STOR.get('PARAM_notifnbr').then((val) => {
if (val !== null) {
this.prmNotifnbr = val;
this._STOR.get('APP_PARAMS').then((appParams) => {
if (appParams !== null) {
this.prmGeolocate = appParams.PARAM_geolocate;
this.prmGeoarea = appParams.PARAM_geoarea;
this.prmNotiftime = appParams.PARAM_notiftime;
this.prmTrackdelay = appParams.PARAM_trackdelay;
this.prmNotifnbr = appParams.PARAM_notifnbr;
}
});
}
......@@ -111,19 +92,38 @@ export class AlloService {
async presentLoading() {
this.showPage = false;
const loading = await this.loadingCtrl.create({
this.loading = await this.loadingCtrl.create({
// spinner: null,
duration: 0,
message: 'Chargement...',
translucent: true,
cssClass: 'custom-class custom-loading'
});
return await loading.present().then(() => {
return await this.loading.present().then(() => {
this.showPage = true;
});
}
dismissLoading() {
this.loadingCtrl.dismiss();
this.loading.dismiss();
}
async presentToast(header, message, position) {
const toast = await this.toastCtrl.create({
message: message,
duration: 3000,
header: header,
position: position,
buttons: [
{
text: 'OK',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}
]
});
toast.present();
}
}
......@@ -7,6 +7,8 @@ import { Router } from '@angular/router';
import { AlloService } from './allo-service';
// import * as firebase from 'firebase/app';
// import 'firebase/auth';
import * as Config from '../constants';
@Injectable({
......@@ -14,6 +16,10 @@ import * as Config from '../constants';
})
export class AuthService {
public infoNicename;
public infoFullname;
public infoEmail;
constructor(
private platform: Platform,
public storage: Storage,
......@@ -21,37 +27,58 @@ export class AuthService {
private httpAdv: HTTP,
private router: Router,
private _ALLO: AlloService
) { }
) {
this.storage.get('wpUser').then(wpUser => {
if (wpUser) {
this.infoNicename = wpUser.user_nicename;
this.infoFullname = wpUser.user_display_name;
this.infoEmail = wpUser.user_email;
}
});
}
// Wordpress
getUser() {
return this.storage.get('wpUser');
}
setUser(user) {
this.infoNicename = user.user_nicename;
this.infoFullname = user.user_display_name;
this.infoEmail = user.user_email;
return this.storage.set('wpUser', user);
}
logOut() {
return this.storage.clear();
return this.storage.remove('wpUser');
}
doLogin(username, password) {
this._ALLO.presentLoading();
doLogin(values) {
let authData = {
username: username,
password: password
username: values.email,
password: values.password
};
if (this.platform.is('cordova')) {
return this.httpAdv.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData, {}).then(result => {
this.setUser(result);
this._ALLO.dismissLoading();
});
} else {
return this.http.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData).subscribe(result => {
this.setUser(result);
this._ALLO.dismissLoading();
});
}
return new Promise<any>((resolve, reject) => {
if (this.platform.is('cordova')) {
this.httpAdv.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData, {}).then(
res => {
this.setUser(res);
resolve(res);
},
err => reject(err)
);
} else {
this.http.post(Config.WORDPRESS_URL + 'wp-json/jwt-auth/v1/token', authData).subscribe(
res => {
this.setUser(res);
resolve(res);
},
err => reject(err)
);
}
});
}
doRegister(user_data, token) {
......@@ -99,4 +126,41 @@ export class AuthService {
this.router.navigateByUrl('/mainslider', { replaceUrl: true });
}
}
// Firebase
firebaseRegister(value) {
return new Promise<any>((resolve, reject) => {
firebase.auth().createUserWithEmailAndPassword(value.email, value.password)
.then(
res => resolve(res),
err => reject(err));
})
}
firebaseLogin(value) {
return new Promise<any>((resolve, reject) => {
firebase.auth().signInWithEmailAndPassword(value.email, value.password)
.then(
res => resolve(res),
err => reject(err));
});
}
firebaseLogout() {
return new Promise((resolve, reject) => {
if (firebase.auth().currentUser) {
firebase.auth().signOut()
.then(() => {
console.log("LOG Out");
resolve();
}).catch((error) => {
reject();
});
}
})
}
firebaseUserDetails() {
return firebase.auth().currentUser;
}
}
export const environment = {
production: true
production: true,
firebase: {
apiKey: 'AIzaSyDCp8ZFLfMtRtCIuFCYbmmcBU5jcu64MIg',
authDomain: 'allo-testeurs-1546348822085.firebaseapp.com',
databaseURL: 'https://allo-testeurs-1546348822085.firebaseio.com',
projectId: 'allo-testeurs-1546348822085',
storageBucket: '',
messagingSenderId: '536597038498',
appId: '1:536597038498:web:7896f1f4b2960e72479efb'
}
};
......@@ -3,7 +3,16 @@
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
production: false,
firebase: {
apiKey: 'AIzaSyDCp8ZFLfMtRtCIuFCYbmmcBU5jcu64MIg',
authDomain: 'allo-testeurs-1546348822085.firebaseapp.com',
databaseURL: 'https://allo-testeurs-1546348822085.firebaseio.com',
projectId: 'allo-testeurs-1546348822085',
storageBucket: '',
messagingSenderId: '536597038498',
appId: '1:536597038498:web:7896f1f4b2960e72479efb'
}
};
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment