(function () {
  "use strict";

  angular.module('mnAuthService', [
    'mnPools',
    'ui.router',
    'mnPendingQueryKeeper',
    'mnPermissions'
  ]).factory('mnAuthService', mnAuthServiceFactory);

  function mnAuthServiceFactory($http, $state, mnPools, $rootScope, mnPendingQueryKeeper, mnPermissions, $uibModalStack) {
    var mnAuthService = {
      login: login,
      logout: logout
    };

    return mnAuthService;

    function login(user) {
      user = user || {};
      return $http({
        method: 'POST',
        url: '/uilogin',
        data: {
          user: user.username,
          password: user.password
        }
      }).then(function (resp) {
        mnPools.clearCache();
        return resp;
      });
    }
    function logout() {
      return $http({
        method: 'POST',
        url: "/uilogout"
      }).then(function () {
        $uibModalStack.dismissAll("uilogout");
        mnPools.clearCache();
        $state.go('app.auth').then(function () {
          delete $rootScope.poolDefault;
          delete $rootScope.pools;
          mnPermissions.clear();
        });
        mnPendingQueryKeeper.cancelAllQueries();
      });
    }
  }
})();


@@ -314,16 +314,25 @@
 dalStack
+, $window
 ) %7B%0A    
@@ -1106,24 +1106,143 @@
         %7D);%0A
+        $window.localStorage.removeItem('mn_xdcr_regex');%0A        $window.localStorage.removeItem('mn_xdcr_testKeys');%0A
         mnPe

remove mn_xdcr_regex and mn_xdcr_testKeys on logout