diff --git a/app/account/account.html b/app/account/account.html
index 089482cd..79f1d458 100644
--- a/app/account/account.html
+++ b/app/account/account.html
@@ -21,11 +21,6 @@
Account
-
\ No newline at end of file
+
diff --git a/app/account/account.js b/app/account/account.js
index d554c098..f5f9041a 100644
--- a/app/account/account.js
+++ b/app/account/account.js
@@ -1,33 +1,30 @@
(function (angular) {
"use strict";
- var app = angular.module('myApp.account', ['firebase', 'firebase.utils', 'firebase.auth', 'ngRoute']);
+ var app = angular.module('myApp.account', ['firebase', 'firebase.appauth', 'ngRoute']);
- app.controller('AccountCtrl', ['$scope', 'Auth', 'fbutil', 'user', '$location', '$firebaseObject',
- function($scope, Auth, fbutil, user, $location, $firebaseObject) {
- var unbind;
+ app.controller('AccountCtrl', ['$scope', 'Auth', '$location', '$firebaseObject',
+ function($scope, Auth, $location, $firebaseObject) {
// create a 3-way binding with the user profile object in Firebase
- var profile = $firebaseObject(fbutil.ref('users', user.uid));
- profile.$bindTo($scope, 'profile').then(function(ub) { unbind = ub; });
+ $scope.profile = Auth.$getAuth();
+ console.log("firebase.User = ",JSON.stringify($scope.profile));
// expose logout function to scope
$scope.logout = function() {
- if( unbind ) { unbind(); }
- profile.$destroy();
- Auth.$unauth();
+ Auth.$signOut();
$location.path('/login');
};
- $scope.changePassword = function(pass, confirm, newPass) {
+ $scope.changePassword = function(newPass, confirm) {
resetMessages();
- if( !pass || !confirm || !newPass ) {
+ if( !confirm || !newPass ) {
$scope.err = 'Please fill in all password fields';
}
else if( newPass !== confirm ) {
$scope.err = 'New pass and confirm do not match';
}
else {
- Auth.$changePassword({email: profile.email, oldPassword: pass, newPassword: newPass})
+ Auth.$updatePassword(newPass)
.then(function() {
$scope.msg = 'Password changed';
}, function(err) {
@@ -38,16 +35,9 @@
$scope.clear = resetMessages;
- $scope.changeEmail = function(pass, newEmail) {
+ $scope.changeEmail = function(newEmail) {
resetMessages();
- var oldEmail = profile.email;
- Auth.$changeEmail({oldEmail: oldEmail, newEmail: newEmail, password: pass})
- .then(function() {
- // store the new email address in the user's profile
- return fbutil.handler(function(done) {
- fbutil.ref('users', user.uid, 'email').set(newEmail, done);
- });
- })
+ Auth.$updateEmail(newEmail)
.then(function() {
$scope.emailmsg = 'Email changed';
}, function(err) {
@@ -74,4 +64,4 @@
})
}]);
-})(angular);
\ No newline at end of file
+})(angular);
diff --git a/app/app.js b/app/app.js
index d038c71f..a1f47995 100644
--- a/app/app.js
+++ b/app/app.js
@@ -2,8 +2,12 @@
// Declare app level module which depends on filters, and services
angular.module('myApp', [
+ 'firebase',
'myApp.config',
'myApp.security',
+
+ 'firebase.appauth',
+
'myApp.home',
'myApp.account',
'myApp.chat',
@@ -11,6 +15,14 @@ angular.module('myApp', [
])
.config(['$routeProvider', function ($routeProvider) {
+ // Initialize Firebase
+ var config = {
+ apiKey: PRIVATE.firebase_api,
+ authDomain: PRIVATE.firebase_authDomain,
+ databaseURL: PRIVATE.firebase_databaseURL
+ };
+ firebase.initializeApp(config);
+
$routeProvider.otherwise({
redirectTo: '/home'
});
@@ -18,7 +30,7 @@ angular.module('myApp', [
.run(['$rootScope', 'Auth', function($rootScope, Auth) {
// track status of authentication
- Auth.$onAuth(function(user) {
+ Auth.$onAuthStateChanged(function(user) {
$rootScope.loggedIn = !!user;
});
}]);
diff --git a/app/chat/chat.js b/app/chat/chat.js
index a720fe35..c96b7407 100644
--- a/app/chat/chat.js
+++ b/app/chat/chat.js
@@ -1,7 +1,7 @@
(function (angular) {
"use strict";
- var app = angular.module('myApp.chat', ['ngRoute', 'firebase.utils', 'firebase']);
+ var app = angular.module('myApp.chat', ['ngRoute', 'firebase']);
app.controller('ChatCtrl', ['$scope', 'messageList', function($scope, messageList) {
$scope.messages = messageList;
@@ -12,8 +12,8 @@
};
}]);
- app.factory('messageList', ['fbutil', '$firebaseArray', function(fbutil, $firebaseArray) {
- var ref = fbutil.ref('messages').limitToLast(10);
+ app.factory('messageList', ['$firebaseArray', function($firebaseArray) {
+ var ref = firebase.database().ref('messages').limitToLast(10);;
return $firebaseArray(ref);
}]);
@@ -24,4 +24,4 @@
});
}]);
-})(angular);
\ No newline at end of file
+})(angular);
diff --git a/app/components/auth/auth.js b/app/components/auth/auth.js
index 7af43941..0be05905 100644
--- a/app/components/auth/auth.js
+++ b/app/components/auth/auth.js
@@ -1,4 +1,6 @@
-angular.module('firebase.auth', ['firebase', 'firebase.utils'])
- .factory('Auth', ['$firebaseAuth', 'fbutil', function($firebaseAuth, fbutil) {
- return $firebaseAuth(fbutil.ref());
+angular.module('firebase.appauth', ['firebase'])
+ // renamed as per
+ // https://stackoverflow.com/questions/39244924/angularfire-and-firebase-upgrade-error-unknown-provider-firebaseauthprovider#39249547
+ .factory('Auth', ['$firebaseAuth', function($firebaseAuth) {
+ return $firebaseAuth();
}]);
diff --git a/app/components/ngcloak/ngcloak-decorator.js b/app/components/ngcloak/ngcloak-decorator.js
index 437f3558..2919a018 100644
--- a/app/components/ngcloak/ngcloak-decorator.js
+++ b/app/components/ngcloak/ngcloak-decorator.js
@@ -16,7 +16,7 @@ angular.module('myApp')
// make a copy of the old directive
var _compile = directive.compile;
directive.compile = function(element, attr) {
- Auth.$waitForAuth().then(function() {
+ Auth.$waitForSignIn().then(function() {
// after auth, run the original ng-cloak directive
_compile.call(directive, element, attr);
});
@@ -24,4 +24,4 @@ angular.module('myApp')
// return the modified directive
return $delegate;
}]);
- }]);
\ No newline at end of file
+ }]);
diff --git a/app/components/security/security.js b/app/components/security/security.js
index e0b30c03..7bc35503 100644
--- a/app/components/security/security.js
+++ b/app/components/security/security.js
@@ -5,7 +5,7 @@
// to be used by authRequired() in the services below
var securedRoutes = [];
- angular.module('myApp.security', ['ngRoute', 'firebase.auth', 'myApp.config'])
+ angular.module('myApp.security', ['ngRoute', 'myApp.config'])
.config(['$routeProvider', function ($routeProvider) {
// routes which are not in our map are redirected to /home
@@ -30,7 +30,7 @@
securedRoutes.push(path); // store all secured routes for use with authRequired() below
route.resolve = route.resolve || {};
route.resolve.user = ['Auth', function (Auth) {
- return Auth.$requireAuth();
+ return Auth.$requireSignIn();
}];
$routeProvider.when(path, route);
return this;
@@ -46,7 +46,7 @@
.run(['$rootScope', '$location', 'Auth', 'loginRedirectPath',
function ($rootScope, $location, Auth, loginRedirectPath) {
// watch for login status changes and redirect if appropriate
- Auth.$onAuth(check);
+ Auth.$onAuthStateChanged(check);
// some of our routes may reject resolve promises with the special {authRequired: true} error
// this redirects to the login page whenever that is encountered
diff --git a/app/config.js b/app/config.js
index 731fb370..7e2de223 100644
--- a/app/config.js
+++ b/app/config.js
@@ -3,20 +3,20 @@
// Declare app level module which depends on filters, and services
angular.module('myApp.config', [])
- // version of this seed app is compatible with angularFire 1.0.0
+ // version of this seed app is compatible with angularFire 2.x.x
// see tags for other versions: https://github.com/firebase/angularFire-seed/tags
- .constant('version', '1.0.0')
+ .constant('version', '2.0.0')
// where to redirect users if they need to authenticate (see security.js)
.constant('loginRedirectPath', '/login')
// your Firebase data URL goes here, no trailing slash
- .constant('FBURL', 'https://angularfire-seed-dev.firebaseio.com')
+ //.constant('FBURL', 'https://peep3auth.firebaseio.com')
// double check that the app has been configured before running it and blowing up space and time
- .run(['FBURL', '$timeout', function(FBURL, $timeout) {
- if( FBURL.match('//INSTANCE.firebaseio.com') ) {
- angular.element(document.body).html('Please configure app/config.js before running!
');
+ .run(['$timeout', function($timeout) {
+ if( PRIVATE.firebase_databaseURL.match('https://INSTANCE.firebaseio.com') ) {
+ angular.element(document.body).html('Please configure app/private.js before running!
');
$timeout(function() {
angular.element(document.body).removeClass('hide');
}, 250);
diff --git a/app/home/home.js b/app/home/home.js
index 0cd50cf9..a3290fda 100644
--- a/app/home/home.js
+++ b/app/home/home.js
@@ -1,12 +1,13 @@
(function(angular) {
"use strict";
- var app = angular.module('myApp.home', ['firebase.auth', 'firebase', 'firebase.utils', 'ngRoute']);
+ var app = angular.module('myApp.home', ['firebase.appauth', 'firebase', 'ngRoute']);
- app.controller('HomeCtrl', ['$scope', 'fbutil', 'user', '$firebaseObject', 'FBURL', function ($scope, fbutil, user, $firebaseObject, FBURL) {
- $scope.syncedValue = $firebaseObject(fbutil.ref('syncedValue'));
- $scope.user = user;
- $scope.FBURL = FBURL;
+ app.controller('HomeCtrl', ['$scope', '$firebaseObject', 'Auth', function ($scope, $firebaseObject, Auth) {
+ var ref = firebase.database().ref('syncedValue');
+ $scope.syncedValue = $firebaseObject(ref);
+ $scope.user = Auth.$getAuth();;
+ $scope.FBURL = PRIVATE.firebase_databaseURL;
}]);
app.config(['$routeProvider', function ($routeProvider) {
@@ -19,7 +20,7 @@
// in the controller, but this makes things cleaner (controller doesn't need to worry
// about auth status or timing of accessing data or displaying elements)
user: ['Auth', function (Auth) {
- return Auth.$waitForAuth();
+ return Auth.$waitForSignIn();
}]
}
});
diff --git a/app/index.html b/app/index.html
index 1687b4a5..a2e015fd 100644
--- a/app/index.html
+++ b/app/index.html
@@ -6,10 +6,10 @@
My AngularJS App
-
-
+
+
-
+
@@ -25,25 +25,25 @@
AngularFire-seed v
-
+
+
-
-
+
diff --git a/app/login/login.html b/app/login/login.html
index 743e84eb..6bf41dbb 100644
--- a/app/login/login.html
+++ b/app/login/login.html
@@ -4,7 +4,7 @@ Login Page