簡體   English   中英

認證后的Ionic / Firebase成功功能

[英]Ionic/Firebase Success function after Auth

我有此登錄功能,正在運行。 但是我只在沒有發現錯誤的情況下才嘗試重定向。 我在下面嘗試了這段代碼,但這不能按我想要的方式工作,任何想法,例如我不知道的成功函數?

 $scope.loginEmail = function($email, $password){ var testing = 1; $scope.error = ''; firebase.auth().signInWithEmailAndPassword($email, $password).catch(function(error) { var errorCode = error.code; var errorMessage = error.message; $scope.error = errorMessage; testing = 0; console.log("Testing 1 : ", testing); }); if(testing === 1) { console.log("Testing 2 : ", testing); $state.go("menu.VNements"); } }; 

該函數返回一個Promise - catch表示錯誤, then表示成功。

function signInSuccess(response) {
  console.log('signInSuccess', response);
}

function signInError(response) {
  console.log('signInError', response);
}

firebase.auth().signInWithEmailAndPassword($email, $password)
  .then(signInSuccess);
  .catch(signInError);

為了更加清晰,我將代碼放在這里,通過Dominic Tobias,它可以正常工作!

 $scope.loginEmail = function($email, $password){ function signInSuccess(response) { console.log('signInSuccess : ', response); $state.go("menu.VNements"); } function signInError(response) { console.log('signInError : ', response); } firebase.auth().signInWithEmailAndPassword($email, $password) .then(signInSuccess) .catch(signInError); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM