Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 98a1ff0

Browse files
committed
Minor formatting changes and update comments.
1 parent ef0cf84 commit 98a1ff0

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

angularfire.js

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,9 @@
282282
};
283283

284284
// Attach an event handler for when the object is changed. You can attach
285-
// handlers for all Firebase events. Additionally, the following events,
286-
// specific to AngularFire, can be attached to.
285+
// handlers for all Firebase events like "child_added", "value", and
286+
// "child_removed". Additionally, the following events, specific to
287+
// AngularFire, can be listened to.
287288
//
288289
// - "change": The provided function will be called whenever the local
289290
// object is modified because the remote data was updated.
@@ -442,6 +443,7 @@
442443
self._updateModel(key, val);
443444
}
444445

446+
// Helper function to attach and broadcast events.
445447
function _handleAndBroadcastEvent(type, handler) {
446448
return function(snapshot, prevChild) {
447449
handler(snapshot, prevChild);
@@ -659,7 +661,8 @@
659661
// will at a minimum contain the `id` and `provider` properties.
660662
//
661663
// The returned object will also have the following methods available:
662-
// $login(), $logout(), $createUser() and $changePassword().
664+
// $login(), $logout(), $createUser(), $changePassword(), $removeUser(),
665+
// and $getCurrentUser().
663666
return function(ref) {
664667
var auth = new AngularFireAuth($q, $t, $rs, ref);
665668
return auth.construct();
@@ -717,8 +720,9 @@
717720
var deferred = this._q.defer();
718721
var self = this;
719722

720-
//To avoid the promise from being fulfilled by our initial login state, make sure we have it before
721-
//triggering the login and creating a new promise.
723+
// To avoid the promise from being fulfilled by our initial login state,
724+
// make sure we have it before triggering the login and creating a new
725+
// promise.
722726
this.getCurrentUser().then(function() {
723727
self._loginDeferred = deferred;
724728
self._authClient.login(provider, options);
@@ -729,17 +733,18 @@
729733

730734
// Unauthenticate the Firebase reference.
731735
logout: function() {
732-
//tell the simple login client to log us out.
736+
// Tell the simple login client to log us out.
733737
this._authClient.logout();
734738

735-
//forget who we were, so that any getCurrentUser calls will wait for another user event.
739+
// Forget who we were, so that any getCurrentUser calls will wait for
740+
// another user event.
736741
delete this._currentUserData;
737742
},
738743

739-
// Creates a user for Firebase Simple Login.
740-
// Function 'cb' receives an error as the first argument and a
741-
// Simple Login user object as the second argument. Pass noLogin=true
742-
// if you don't want the newly created user to also be logged in.
744+
// Creates a user for Firebase Simple Login. Function 'cb' receives an
745+
// error as the first argument and a Simple Login user object as the second
746+
// argument. Set the optional 'noLogin' argument to true if you don't want
747+
// the newly created user to also be logged in.
743748
createUser: function(email, password, noLogin) {
744749
var self = this;
745750
var deferred = this._q.defer();
@@ -750,8 +755,11 @@
750755
deferred.reject(err);
751756
} else {
752757
if (!noLogin) {
753-
//resolve the promise with a new promise for login
754-
deferred.resolve(self.login("password", {email: email, password: password}));
758+
// Resolve the promise with a new promise for login.
759+
deferred.resolve(self.login("password", {
760+
email: email,
761+
password: password
762+
}));
755763
} else {
756764
deferred.resolve(user);
757765
}
@@ -761,26 +769,28 @@
761769
return deferred.promise;
762770
},
763771

764-
// Changes the password for a Firebase Simple Login user.
765-
// Take an email, old password and new password as three mandatory
766-
// arguments. Returns a promise.
772+
// Changes the password for a Firebase Simple Login user. Take an email,
773+
// old password and new password as three mandatory arguments. Returns a
774+
// promise.
767775
changePassword: function(email, oldPassword, newPassword) {
768776
var self = this;
769777
var deferred = this._q.defer();
770778

771-
self._authClient.changePassword(email, oldPassword, newPassword, function(err) {
772-
if (err) {
773-
self._rootScope.$broadcast("$firebaseSimpleLogin:error", err);
774-
deferred.reject(err);
775-
} else {
776-
deferred.resolve();
779+
self._authClient.changePassword(email, oldPassword, newPassword,
780+
function(err) {
781+
if (err) {
782+
self._rootScope.$broadcast("$firebaseSimpleLogin:error", err);
783+
deferred.reject(err);
784+
} else {
785+
deferred.resolve();
786+
}
777787
}
778-
});
788+
);
779789

780790
return deferred.promise;
781791
},
782792

783-
//Gets a promise for the current user info
793+
// Gets a promise for the current user info.
784794
getCurrentUser: function() {
785795
var self = this;
786796
var deferred = this._q.defer();
@@ -794,7 +804,7 @@
794804
return deferred.promise;
795805
},
796806

797-
//Remove a user for the listed email address. Returns a promise.
807+
// Remove a user for the listed email address. Returns a promise.
798808
removeUser: function(email, password) {
799809
var self = this;
800810
var deferred = this._q.defer();
@@ -811,18 +821,18 @@
811821
return deferred.promise;
812822
},
813823

814-
//Send a password reset email to the user for an email + password account.
815-
//resetPassword: function() {
816-
//coming soon...
824+
// Send a password reset email to the user for an email + password account.
825+
// resetPassword: function() {
826+
// Stub: Coming soon to Simple Login.
817827
//},
818828

819829
// Internal callback for any Simple Login event.
820830
_onLoginEvent: function(err, user) {
821-
822831
// HACK -- calls to logout() trigger events even if we're not logged in,
823832
// making us get extra events. Throw them away. This should be fixed by
824-
// changing Simple Login so that its callbacks refer directly to the action that caused them.
825-
if(this._currentUserData === user && err === null) {
833+
// changing Simple Login so that its callbacks refer directly to the
834+
// action that caused them.
835+
if (this._currentUserData === user && err === null) {
826836
return;
827837
}
828838

0 commit comments

Comments
 (0)