Skip to content

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

@hughred22

Description

@hughred22

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions