电子邮件认证

问题描述:

我无法重定向成功登录后,用户

后重定向,我读过了火力地堡的文档,并试图几件事情,但至今没有运气电子邮件认证

任何人都可以点我到正确的方向?

在此先感谢, 热雷米。

这里的controller.js

.controller('LoginCtrl', function($scope, $ionicPopup, $state, Auth) { 
$scope.data = {}; 

$scope.login = function() { 
     Auth.login($scope.data.email, $scope.data.password).then(function() { 
     $state.go("tab-discover"); 
       }) 

    .error(function() { 
     var alertPopup = $ionicPopup.show({ 
      title: 'Mauvais identifiants', 
      template: 'Veuillez recommencer' 
     }); 
    }); 
} 

$scope.signup = function() { 
     Auth.signup($scope.data.email, $scope.data.password) 
    .error(function() { 
     var alertPopup = $ionicPopup.show({ 
      title: 'Erreur', 
      template: 'Un probleme est survenu' 
     }); 
     }); 
    } 

    }) 

而且services.js

.factory("Auth", function(FURL, $firebaseAuth) { 


    var ref = new Firebase(FURL); 
    var auth = $firebaseAuth(ref); 
    var Auth = { 
    user: {}, 

login: function(email, password){ 
    console.log("loginService", email, password); 

    return ref.authWithPassword({ 
    "email": email, 
    "password": password 
    }, function(error, authData) { 


    if (error) { 
    console.log("La connexion a echoué!", error); 
    } else { 
    console.log("Authenticated successfully with payload:", authData); 
    } 
}) 
    }, 
    signup: function(email, password){ 
     console.log("signupService", email, password); 
     return ref.createUser({ 
     "email": email, 
     "password": password 
     }, function(error, userData) { 
    if (error) { 
    switch (error.code) { 
     case "EMAIL_TAKEN": 
     console.log("The new user account cannot be created because the email is already in use."); 
     break; 
     case "INVALID_EMAIL": 
     console.log("The specified email is not a valid email."); 
     break; 
     default: 
     console.log("Error creating user:", error); 
    } 
    } else { 
    console.log("Successfully created user account with uid:", userData.uid); 
    } 
}).then(function(){ 
     return Auth.login(email, password); 
    }) 
    } 
} 
return Auth; 
}) 
+0

重定向,比如'了window.location =“someotherlocation “;'? – Filipe

+0

@Filipe OP是采用了棱角分明的路由重定向,在$ state.go(..)线 – aw04

看起来火力使用,你试图把它返回与then承诺回调。一个简单的解决将是一个回调传递给您的登录功能,并调用它的火力点回调中:

login: function(email, password, callback, onError){ 
    console.log("loginService", email, password); 

    ref.authWithPassword({ 
    "email": email, 
    "password": password 
    }, function(error, authData) { 

    if (error) { 
    onError(error); 
    } else { 
    callback(authData); 
    } 
}) 

然后调用它像这样:

Auth.login($scope.data.email, $scope.data.password, function (data) { 
    console.log("Authenticated successfully with payload:", data); 
    $state.go("tab-discover"); 
}, function (error) { 
    console.log("La connexion a echoué!", error); 
}); 
+0

我得到750853错误类型错误:在范围无法读取属性“然后”未定义 $ scope.login(HTTP://本地主机:8100/JS/controllers.js:7:62)和751852警告火力警告:异常是由用户回调抛出。类型错误:回调不是一个函数 –

+0

我删除了,然后从代码,如果你得到的错误是不是我提供的 – aw04

+0

你说得对,我的坏 感谢现在的工作 –