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

Commit

Permalink
Merge branch 'passwordFuncs' of github.com:sfeast/firebase-element in…
Browse files Browse the repository at this point in the history
…to sfeast-passwordFuncs
  • Loading branch information
kevinpschaaf committed Aug 5, 2014
2 parents 59c65dc + 91f0f4a commit e764162
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions 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,6 +174,51 @@
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 e764162

Please sign in to comment.