密码重置后,Firebase Auth不会更新

dmo*_*dmo 5 authentication angularjs firebase

一旦第一次加载Firebase Auth对象,我似乎无法弄清楚如何重置它.

我正在寻找强制用户重置密码的bool trueauth.password.isTemporaryPassword.一旦用户执行了此过程并重置,则auth.password.isTemporaryPassword保留true.

我找到的唯一方法是将用户注销并再次登录,刷新auth对象.

登录:

var ref = new Firebase(environment);

$firebaseAuth(ref)
.$authWithPassword({
     email: email,
     password: password
},sessionObj)
.then(function(authData) {
    if (password.isTemporaryPassword === true) {
        $state.go('resetpassword');
    }
})
.catch(function(error) {
    deferred.reject(error);
});
Run Code Online (Sandbox Code Playgroud)

重设密码:

$scope.reset.oldPassword         =  "oldPass";
$scope.reset.newPassword         =  "newPass";
$scope.reset.email              =   "usermail";

ref.changePassword($scope.reset, function(err) {
    if(err) {
         ...
    }
    else {
        $state.go('home')
    }
})
Run Code Online (Sandbox Code Playgroud)

password.isTemporaryPassword保持true,直到我再次登录用户似乎哈克.

小智 0

您应该能够使用该onAuth函数来侦听身份验证状态的更改:

ref.onAuth(function(authData) {

    //user authenticated & needs to change her password
    if(authData && authData.password.isTemporaryPassword) {
        $state.go('resetpassword');
    }

    //else user is logged in with valid password
    else if(authData) {

    }

    //else user is logged out
    else {

    }
});
Run Code Online (Sandbox Code Playgroud)