$ authWithPassword始终返回"指定的密码不正确。"

时间:2016-03-15 09:20:44

标签: angularjs coffeescript firebase angularfire firebase-authentication

我正在尝试使用angularfire(firebase)通过密码实现身份验证。 javascript是用coffeescript(!)实现的。 创建用户,所有其他firebase功能似乎都可以正常工作。

但是,当使用$ authWithPassword尝试登录用户时,它总是返回错误"指定的密码不正确。"无论密码是什么。

实施方式: 在coffeescript中:

$scope.loginUser = ()->
        console.log("logging in! "+ $scope.loginEmail + " "+$scope.loginPassword)
        $scope.auth.$authWithPassword({"email": $scope.loginEmail,  "password": $scope.loginPassword})
        .then (authData)->
            $scope.authData = authData
            console.log(authData)
            $mdToast.showSimple("welcome!")
            return
        .catch (error)-> 
            console.log(error)
            $mdToast.showSimple("there was a problem")
            return
        return

..它总是返回"有一个问题......并且控制台说问题是密码" 什么地方出了错? (我仔细检查过 - 这不是密码。)

翻译为javascript:

$scope.loginUser = function() {
  console.log("logging in! " + $scope.loginEmail + " " + $scope.loginPassword);
  $scope.auth.$authWithPassword({
    "email": $scope.loginEmail,
    "password": $scope.loginPassword
  }).then(function(authData) {
    $scope.authData = authData;
    console.log(authData);
    $mdToast.showSimple("welcome!");
  })["catch"](function(error) {
    console.log(error);
    $mdToast.showSimple("there was a problem");
  });
};

---编辑--- 使用的html标记:

<md-card-content>
              <div>
                <md-input-container>
                  <input placeholder="email" type="email" ng-model="loginEmail">
                </md-input-container>
                <md-input-container>
                  <input placeholder="password" type="password" ng-model="loginPassword">
                </md-input-container>
              </div>
              <div><span></span>
                <md-button ng-click="loginUser()" class="md-primary">
                  <md-icon>person</md-icon><span style="font-size:16px">connect</span>
                </md-button>
              </div>
</md-card-content>

我想提一下,即使将用户名和密码硬编码到javascript中,它仍然无法登录。所以它在html部分中似乎不是一个问题。此外,loginUser()函数会触发,因为我在控制台中收到错误消息。

1 个答案:

答案 0 :(得分:0)

很抱歉,我在代码的其他地方发现了这个错误。问题在于创建新用户,我有一个代码可以为密码添加一些字符,实际上我尝试登录的密码总是出错。所以上面的代码现在工作正常。 谢谢。