Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Adding password provider specific functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeast committed Jun 30, 2014
1 parent 8e38226 commit 3038ca9
Showing 1 changed file with 77 additions and 1 deletion.
78 changes: 77 additions & 1 deletion firebase-login.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@
* @event error
*/

/**
* Fired when user is created (password provider type)
*
* @event user-created
*/

/**
* Fired when user changes their password (password provider type)
*
* @event password-changed
*/

/**
* Fired when password reset email is sent (password provider type)
*
* @event password-reset
*/

/**
* Fired when user is removed (password provider type)
*
* @event removed-user
*/

/**
* Firebase location URL (must have simple login enabled via Forge interface).
* @attribute location
Expand Down Expand Up @@ -78,6 +102,13 @@
*/
params: null,

/**
* When using a password provider this allows passwords to be required (Firebase does not require passwords)
* @attribute passwordRequired
* @type Boolean
*/
passwordRequired: false,

ready: function() {
if (!this.location) {
// FIXME(kschaaf): doesn't seem to be a way to un-register auth callbacks, so
Expand Down Expand Up @@ -143,7 +174,52 @@
this.login(this.queuedLogin.provider, this.queuedLogin.params);
this.queuedLogin = null;
}
}
},

create: function(email, password) {
if (this.passwordRequired && email != "" && password == "") {
this.fire('error', {message:{message:"Password required"}})
return;
}

this.auth.createUser(email, password, function(error, user) {
if (!error) {
this.fire('user-created', {user: user});
} else {
this.fire('error', {message: error});
}
}.bind(this));
},

changePassword: function(email, oldPassword, newPassword) {
this.auth.changePassword(email, oldPassword, newPassword, function(error, success) {
if (!error) {
this.fire('password-changed');
} else {
this.fire('error', {message: error});
}
}.bind(this));
},

sendPasswordResetEmail: function(email) {
this.auth.sendPasswordResetEmail(email, function(error, success) {
if (!error) {
this.fire('password-reset');
} else {
this.fire('error', {message: error});
}
}.bind(this));
},

removeUser: function(email, password) {
this.auth.removeUser(email, password, function(error, success) {
if (!error) {
this.fire('removed-user');
} else {
this.fire('error', {message: error});
}
}.bind(this));
}

});

Expand Down

0 comments on commit 3038ca9

Please sign in to comment.