any can help me?
how to set admin and user login go to the different page.
userservice.ts
import { Http } from ‘@angular/http’;
import { Injectable } from ‘@angular/core’;
import * as firebase from ‘firebase’;
/*
Generated class for the UserserviceProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class UserserviceProvider {
public data: any;
public fireAuth: any;
public userProfile: any;
constructor(public http: Http) {
this.fireAuth = firebase.auth();
this.userProfile = firebase.database().ref('users');
}
loginUserService(email: string, password: string): any {
return this.fireAuth.signInWithEmailAndPassword(email, password);
} //call firebase
signupUser(account: {}): Promise {
return firebase.auth().createUserWithEmailAndPassword(account[‘email’], account[‘password’]).then(newUser => {
firebase.database().ref(userProfile/${firebase.auth().currentUser.uid}
).set(account);
});
}
}
home.ts ( login page)
import { Component } from ‘@angular/core’;
import { NavController, NavParams, LoadingController, ToastController } from ‘ionic-angular’;
import { UserserviceProvider } from ‘…/…/providers/userservice/userservice’;
import { RegisterPage } from ‘…/register/register’;
import { FirstpagePage } from ‘…/firstpage/firstpage’;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’,
providers: [UserserviceProvider]
})
export class HomePage {
public email: string;
public password: string;
constructor(public usersService : UserserviceProvider,
public loadingCtrl: LoadingController, public toastCtrl: ToastController,
public navCtrl: NavController, public navParams: NavParams) {
}
signIn(){
var that = this;
var loader = this.loadingCtrl.create({
content: "Please wait..."
});
loader.present();
this.usersService.loginUserService(this.email, this.password).then(authData => {
//successful
loader.dismiss();
that.navCtrl.setRoot(FirstpagePage);
}, error => {
loader.dismiss();
// Unable to log in
let toast = this.toastCtrl.create({
message: error,
duration: 3000,
position: 'top'
});
toast.present();
that.password = ""//empty the password field
});
}
resetPwd(){}
register(){
this.navCtrl.push(RegisterPage);
}
}