위로 Parse를 사용하면 SDK가 세션 데이터를 로컬에 저장하고 사용자가 페이지를 새로 고친 후 다시 로그인 할 필요가없는 것처럼 보였습니다. 앱). Firebase/Angularfire의 경우에는 그렇지 않습니다. 매번 웹 페이지를 새로 고침 할 때마다 인증 데이터가 많이 수집됩니다. 이것은 Firebase의 멋진 사람들이 구현하지 않은 것에 대해 놀랄 것입니다. 내가 놓친 게 있니?Ionic app/페이지를 다시로드 한 후 Firebase 자동 로그인
완전성을 위해;
// ASG june 2016 - Upgrade firebase SDK
firebase.initializeApp(FirebaseConfig);
// login as anonymous if not already logged in
var currentUser = $firebaseAuth().$getAuth();
if (currentUser) {
console.log("Signed in as:", currentUser);
} else {
console.log("Not logged in; going to log in as anonymous");
$firebaseAuth().$signInAnonymously().then(function(authData) {
console.log("Signed in anonymously as:", authData.uid);
}).catch(function(error) {
console.error("Anonymous authentication failed:", error);
});
}
// register the on auth callback
$firebaseAuth().$onAuthStateChanged(function(authData) {
if (authData) {
console.log("Logged in as:", authData.uid);
if(typeof($rootScope.userProfile) == "undefined"){
$rootScope.userProfile = FirebaseProfileService.getUserProfile(authData.uid, false);
}
}
});
getAuth를 사용하지 않고 현재 로그인 한 사용자에 대한 데이터를 얻으려면 어떻게해야합니까? 사용자가 로그인했는지 여부를 확인하고 싶은 다른 주에서는? – rex
나는 사용자가 이미 로그인되어 있고이 데이터가 지속되는 경우 getAuth가 null을 반환하는 이유를 조금 혼란스러워합니다. – rex
필자는 app.run()에 넣기 때문에 가끔은 경쟁 조건으로 이어지기 때문에 다른 컨트롤러와 서비스에 의해 태클 될 다른 상태에서는 괜찮을 것이라고 생각합니다. 다시, 나는 단지 생각하고 여기에 아무것도 내 측면에서 테스트입니다 추측입니다. 그러나 시도하고 알려주세요. –