Pregunta

I'm trying to remove a user in my angularfire project. The email and password get passed correctly but for some reason this method doesn't get executed. Here is the code in my Authentication service (I added some explanatory comments):

removeUser: function (email, password) {

                console.log(email); --> Correct Email
                console.log(password); --> Correct password

                auth.$removeUser(email, password, function (succes, error) {
                    console.log('in removeUser'); --> Does not print
                    if (!error) {
                        console.log('user deleted'); --> Also doesn't print
                    } else {
                        console.log(error); --> You guessed it, doesn't print
                    }
                });
                console.log('Why am I even here?'); --> Does print
            }

The auth variable is correct and I am not getting any errors.

This is how I get my angularfire ref, other methods such as $createUser and $login are working correcty:

var ref = new Firebase(FIREBASE_URL);

var auth = $firebaseSimpleLogin(ref);

EDIT#2: I noticed that resetpassword does work, but the callback doesn't happen. Does anyone know why? Whether I give in a wrong or a correct oldpassword, it doesn't print anything

resetpassword: function (email, oldPassword, newPassword) {
                return auth.$changePassword(email, oldPassword, newPassword, function (error) {
                    console.log('in resetpass auth'); //doesn't print, no errors
                    if (!error) {
                        console.log('Password changed succesfully'); 
                    } else {
                        console.log(error); 
                    }
                });
            }
¿Fue útil?

Solución

When using Firebase Simple Login directly, the methods you reference above accept callbacks as the final argument. However, when using Firebase + AngularJS via AngularFire, these methods are wrapped to be friendlier to Angular development, and return promises rather than accepted callbacks.

See https://www.firebase.com/docs/angular/reference.html#changepassword-email-oldpassword-newpassword for more details.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top