Only trigger onUserLogged(In|Out) if login state actually changed
This also includes triggering an initial onUserLoggedIn after initialization if the user turned out to be logged in by passive login.
This commit is contained in:
parent
8aec836d22
commit
96ee80afd2
1 changed files with 9 additions and 4 deletions
|
|
@ -52,16 +52,21 @@ $(function() {
|
|||
|
||||
self.fromResponse = function(response) {
|
||||
var process = function() {
|
||||
var currentLoggedIn = self.loggedIn();
|
||||
if (response && response.name) {
|
||||
self.loggedIn(true);
|
||||
self.updateCurrentUserData(response);
|
||||
callViewModels(self.allViewModels, "onUserLoggedIn", [response]);
|
||||
log.info("User " + response.name + " logged in")
|
||||
if (!currentLoggedIn) {
|
||||
callViewModels(self.allViewModels, "onUserLoggedIn", [response]);
|
||||
log.info("User " + response.name + " logged in")
|
||||
}
|
||||
} else {
|
||||
self.loggedIn(false);
|
||||
self.resetCurrentUserData();
|
||||
callViewModels(self.allViewModels, "onUserLoggedOut");
|
||||
log.info("User logged out");
|
||||
if (currentLoggedIn) {
|
||||
callViewModels(self.allViewModels, "onUserLoggedOut");
|
||||
log.info("User logged out");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue