Open hughred22 opened 9 years ago
I guess the simplest solution is to clear the history once the user has successfully logged in and navigated to the tabs interface. $ionicHistory. clearHistory()
. More info here: http://ionicframework.com/docs/api/service/$ionicHistory/
So I think I found an architecture error on how you structure the MainCtrl. Would love to know how I can solve this in the best way.
So let's assume user can go back to main.html after they successfully login - either via forced URL on browser, or back button, or $urlRouterProvider.otherwise, or just simply link back. It will throw an error: Error: Attempted to assign to readonly property. And what is worse, it create a NEW online user in the Firebase OlineUsers node - with exactly same email, same name, same everything except date object. (duplicated records).
So question 1: Instead of if (currentAuth) { $scope.$broadcast('showChatInterface', currentAuth.google); }
Should I just do this? if (currentAuth) { $state.go('tab.dash'); }
I don't understand why you need to broadcast 'showChatInterface' again. If the controller return currentAuth object, is that mean user is already login? Why we need to recreate the interface again? Is that a special reason I was missing?
If $scope.$broadcast('showChatInterface', currentAuth.google); is necessary, what should I do to stop duplicate record? I think the error is causing by this line: UserFactory.setUser(authData);
Thanks!