diff --git a/frontend/app/index.html b/frontend/app/index.html
index f6b081c997..ec9828b2ee 100644
--- a/frontend/app/index.html
+++ b/frontend/app/index.html
@@ -133,6 +133,7 @@
+
diff --git a/frontend/app/scripts/components/organisation/OrgSwitchCtrl.js b/frontend/app/scripts/components/organisation/OrgSwitchCtrl.js
new file mode 100644
index 0000000000..39873534ca
--- /dev/null
+++ b/frontend/app/scripts/components/organisation/OrgSwitchCtrl.js
@@ -0,0 +1,18 @@
+(function() {
+ 'use strict';
+
+ angular.module('theHiveControllers').controller('OrgSwitchCtrl',
+ function($uibModalInstance, currentUser) {
+ //var self = this;
+
+ this.currentUser = currentUser;
+
+ this.selectOrg = function(selected) {
+ $uibModalInstance.close(selected);
+ };
+
+ this.cancel = function() {
+ $uibModalInstance.dismiss();
+ };
+ });
+})();
diff --git a/frontend/app/scripts/controllers/RootCtrl.js b/frontend/app/scripts/controllers/RootCtrl.js
index bf76b3a7a2..15c3f71ec2 100644
--- a/frontend/app/scripts/controllers/RootCtrl.js
+++ b/frontend/app/scripts/controllers/RootCtrl.js
@@ -133,6 +133,40 @@ angular.module('theHiveControllers').controller('RootCtrl',
});
};
+ $scope.switchOrg = function() {
+ var modal = $uibModal.open({
+ templateUrl: 'views/components/org/orgSwitch.modal.html',
+ controller: 'OrgSwitchCtrl',
+ controllerAs: '$dialog',
+ resolve: {
+ currentUser: $scope.currentUser
+ }
+ });
+
+ modal.result
+ .then(function(organisation) {
+ console.log(organisation);
+
+ $rootScope.isLoading = true;
+
+ AuthenticationSrv.current(organisation)
+ .then(function(/*userData*/) {
+ $rootScope.isLoading = false;
+ $state.go('app.index');
+ })
+ .catch( function(err) {
+ NotificationSrv.error('App', err.data, err.status);
+ $rootScope.isLoading = false;
+ });
+ })
+ .catch(function(err) {
+ if(err && !_.isString(err)) {
+ NotificationSrv.error('Switch organisation', err.data, err.status);
+ }
+ });
+
+ };
+
$scope.createNewCase = function(template) {
var modal = $uibModal.open({
templateUrl: 'views/partials/case/case.creation.html',
diff --git a/frontend/app/scripts/services/api/AuthenticationSrv.js b/frontend/app/scripts/services/api/AuthenticationSrv.js
index 88c8269e62..9fd29e3e71 100644
--- a/frontend/app/scripts/services/api/AuthenticationSrv.js
+++ b/frontend/app/scripts/services/api/AuthenticationSrv.js
@@ -33,10 +33,18 @@
}
});
},
- current: function() {
+ current: function(organisation) {
var result = {};
+
+ var options = {};
+ if(organisation) {
+ options.headers = {
+ 'X-Organisation': organisation
+ };
+ }
+
return $http
- .get('./api/v1/user/current')
+ .get('./api/v1/user/current', options)
.then(function(response) {
self.currentUser = response.data;
UtilsSrv.shallowClearAndCopy(response.data, result);
diff --git a/frontend/app/views/components/header.component.html b/frontend/app/views/components/header.component.html
index 24320f477d..a47c51cfee 100644
--- a/frontend/app/views/components/header.component.html
+++ b/frontend/app/views/components/header.component.html
@@ -133,7 +133,7 @@
Analyzer templates
-
+