Forgive me if I'm not using the correct terminology. I am trying to 
conditionally implement a redirect (to an external link, if that makes a 
difference) after clearing session state (this is part of a logout flow). 
However, what happens is that when the session state is cleared the views 
bound to that session state data model are updated, the user sees a view 
where all the data is missing (this is bad) and then the redirect happens. 
I suspect what's happening is 1) the session state is cleared, 2) the views 
are updated, 3) the redirect happens. What I'd like to happen is 1) the 
session state is cleared, 2) the redirect happens (essentially, I don't 
need the view to updated). Keep in mind, this logout flow can happen from 
any view in our site. Here's some abbreviated code I'm working with. The 
flow is signout is called, this calls bootstrapService.signoutUser(), this 
calls signout.get(), then my session state is cleared, then the promise is 
returned back to signout and the we redirect or change state to "signin". 
However, since $rootScope.bootstrapData = null and we've called 
session.$unset() so the view is updated before the redirect.

angular.module('module').controller('controller', function ($state, $scope, 
bootstrapService, profile) {

  $scope.profile = profile;

  $scope.signout = function () {
    bootstrapService.signoutUser().then(function (redirectUrl) {

      if(redirectUrl){

        $window.location.href = redirectUrl;

      } else {

        $state.go('signin');

      }
    });
  };
});



angular.module('another module')

  .factory('bootstrapService', function ($state, $rootScope, $http, $window, 
$q, signout, cs, session, $resource) {
    return {

      bootstrapUser : function () {
        return fetchBootstrapData().then(fetchMoreBootstrapData).then(function 
(data) {
          $rootScope.bootstrapData = data;
          return data;
        });
      },
      signoutUser : function (scope) {
        return signout.get().$promise.then(function (res) {
          $rootScope.bootstrapData = null;
          session.$unset();

          if(res.redirectUrl){

            return res.redirectUrl;

          }
        });
      }
    };
  })


bas

blah


foo

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to