2016-01-08 1 views
0

Я только что начал angularfire Auth! И я получаю эту проблему, когда я вхожу в систему, И если у вас есть какие-либо советы о том, как сделать регистрационную форму электронной почты, я был бы более чем рад это услышать. Здесь ошибка я получаю:Пользователь Auth With AngularJs

Error: Firebase.authWithPassword failed: First argument must be a valid object.

Вот мои script.js:

var app = angular.module('LoginApp', ["firebase"]) 
app.controller('AuthCtrl', [ 
    '$scope', '$rootScope', '$firebaseAuth', function($scope, $rootScope, $firebaseAuth) { 

    var ref = new Firebase('https://uniquecoders.firebaseio.com/') 
    $scope.auth = $firebaseAuth(ref); 

    $scope.signIn = function(){ 
    var ref = new Firebase('https://uniquecoders.firebaseio.com/') 
    ref.authWithPassword('email', { 
     email: $scope.signInEmail, 
     password: $scope.signInPassword 
    }, function(error,userData){ 
     if(error = 'INVALID_EMAIL'){ 
      alert("The Email you entered is Invalid") 
     } 
     else if(error = 'INVALID_PASSWORD'){ 
      alert("The Password you entered is Invalid") 
     } 
     else{ 
      console.log(error) 
     } 
    }) 

    } 
    }] 
); 

и наш Index.html:

<!DOCTYPE html> 
<html lang="en-US"> 
<head> 
     <script src="jquery.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> 
    <script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script> 
    <script src="https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.min.js"></script> 
    <script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script> 
    <script src = "http://s.codepen.io/assets/libs/modernizr.js"></script> 
    <script type="text/javascript" src="script.js"></script> 

    <meta charset="UTF-8"> 
    <meta name="X-UA-Compatible" content=""> 
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
    <meta name="keywords" content=""> 
    <meta name="description" content=""> 
    <title>Login - UniqueCoders</title> 
    <link rel="icon" href="favicon.ico"> 
    <link rel="stylesheet" href="main.css"> 
</head> 
<body ng-app="LoginApp"> 
    <div id="page"> 
     <header class="container"> 
      <div class="row"> 
       <img src="https://lh5.googleusercontent.com/-UXr_le-DEc4/VogTLE2yDfI/AAAAAAAAAfI/9RycRDVGNu8/w993-h207-no/uniquecoders.png" alt="UniqueCoders"> 
      </div> 
     </header> 
     <main class="container"> 
      <div class="row login"> 
       <form ng-controller="AuthCtrl"> 
        <input type="email" name="email" placeholder="Email" ng-model = "signInemail" id="email"> 
        <input type="password" name="password" ng-model = "signInpassword" placeholder="Password" id="password"> 
        <input type="submit" value="Login" ng-click = "signIn()"> 
       </form> 
      </div> 
     </main> 
     <footer class="container"> 
      <div class="row"> 
       <small>&copy; 2016. Unique Coders</small> 
      </div> 
     </footer> 
    </div> 
    <!-- Scripts at the end for faster loading --> 

</body> 
</html> 
+0

Удалить первый аргумент:... 'Ref.authWithPassword («электронной почты»,' –

ответ

1

Из документации здесь что я вижу: https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-users-and-authentication

var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com"); 
ref.authWithPassword({ 
    "email": "[email protected]", 
    "password": "password" 
    }, function(error, authData) { 
    if (error) { 
     console.log("Login Failed!", error); 
    } else { 
     console.log("Authenticated successfully with payload:", authData); 
    } 
}); 

Вы можете изменить его выше и проверить, работает ли оно. Вот простой пример того, как выполнять аутентификацию с помощью angularjs.

http://jasonwatmore.com/post/2015/03/10/AngularJS-User-Registration-and-Login-Example.aspx

+0

Thalivar но то проверка на определенный адрес электронной почты, я хочу, хотел, чтобы проверить, если он имеет все письма и большое спасибо так много для эта ссылка!: D –

+0

@JohnDoe: Где в вашем коде вы проверяете все электронные письма. – Thalaivar