{{neighbour.tagLine}}
-Error: {{ error.code }}
diff --git a/app/pages/login/login.ts b/app/pages/login/login.ts index f0c20f1..2744841 100644 --- a/app/pages/login/login.ts +++ b/app/pages/login/login.ts @@ -1,6 +1,8 @@ import {Modal, NavController, Page, ViewController} from 'ionic-angular'; import {Component, OnInit, Inject} from '@angular/core'; import {AngularFire, AuthProviders, AuthMethods } from 'angularfire2'; +import {AuthProvider} from "../../providers/auth/auth"; +import {TabsPage} from "../tabs/tabs" @Page({ templateUrl: 'build/pages/login/login.html' @@ -9,27 +11,20 @@ export class LoginPage { error: any - constructor(public af: AngularFire, - public viewCtrl: ViewController) { } - /** - * this will dismiss the modal page - */ + constructor( + private navCtrl: NavController, + public af: AngularFire, + public viewCtrl: ViewController, + private auth: AuthProvider) { + + } + dismiss() { this.viewCtrl.dismiss(); } - /** - * this create in the user using the form credentials. - * - * we are preventing the default behavor of submitting - * the form - * - * @param _credentials {Object} the email and password from the form - * @param _event {Object} the event information from the form submit - */ + registerUser(_credentials, _event) { _event.preventDefault(); - - this.af.auth.createUser(_credentials) .then((user) => { console.log(`Create User Success:`, user); @@ -40,59 +35,6 @@ export class LoginPage { .catch(e => console.error(`Create User Failure:`, e)); } - registerUserWithFacebook(_credentials, _event) { - _event.preventDefault(); - - this.af.auth.login({ - provider: AuthProviders.Facebook, - method: AuthMethods.Popup - }).then((value) => { - this.dismiss() - }).catch((error) => { - this.error = error - console.log(error) - }); - } - - - registerUserWithTwitter(_credentials, _event) { - _event.preventDefault(); - - this.af.auth.login({ - provider: AuthProviders.Twitter, - method: AuthMethods.Redirect - }).then((authData) => { - console.log(authData) - - // already has user... need better info?? - if (!authData) { - this.dismiss() - } - - - const itemObservable = this.af.database.object('/users/' + authData.uid); - itemObservable.set({ - "provider": authData.auth.providerData[0].providerId, - "avatar": authData.auth.photoURL || "MISSING", - "displayName": authData.auth.providerData[0].displayName || authData.auth.email, - }) - - }).then((value) => { - this.dismiss() - }).catch((error) => { - this.error = error - console.log(error) - }); - } - /** - * this logs in the user using the form credentials. - * - * if the user is a new user, then we need to create the user AFTER - * we have successfully logged in - * - * @param _credentials {Object} the email and password from the form - * @param _event {Object} the event information from the form submit - */ login(credentials, _event) { _event.preventDefault(); @@ -125,4 +67,12 @@ export class LoginPage { console.log(error) }); } + + registerUserWithGoogleUsingPopupFirebase() { + this.auth.loginWithGoogleUsingPopupFirebase().subscribe(data => { + this.navCtrl.setRoot(TabsPage); + }, err => { + this.error = err; + }); + } } \ No newline at end of file diff --git a/app/pages/settings/settings.html b/app/pages/settings/settings.html index e8f931a..3a2eaf4 100644 --- a/app/pages/settings/settings.html +++ b/app/pages/settings/settings.html @@ -63,18 +63,18 @@