Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go back to main page throw error. Firebase session management issue... #2

Open
hughred22 opened this issue Aug 17, 2015 · 1 comment

Comments

@hughred22
Copy link

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!

@arvindr21
Copy link
Member

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants