mirror of
https://github.com/bitwarden/web
synced 2025-12-10 13:23:15 +00:00
add new org to profile
This commit is contained in:
@@ -80,6 +80,26 @@ angular
|
|||||||
apiService.accounts.getProfile({}, loadProfile);
|
apiService.accounts.getProfile({}, loadProfile);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_service.addProfileOrganization = function (org) {
|
||||||
|
var profile = _service.getUserProfile();
|
||||||
|
if (profile) {
|
||||||
|
if (!profile.Organizations) {
|
||||||
|
profile.Organizations = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var org = {
|
||||||
|
id: org.Id,
|
||||||
|
name: org.Name,
|
||||||
|
key: org.Key,
|
||||||
|
status: org.Status
|
||||||
|
};
|
||||||
|
profile.organizations.push(org);
|
||||||
|
|
||||||
|
_userProfile = profile;
|
||||||
|
cryptoService.addOrgKey(org);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function loadProfile(profile) {
|
function loadProfile(profile) {
|
||||||
_userProfile.extended = {
|
_userProfile.extended = {
|
||||||
name: profile.Name,
|
name: profile.Name,
|
||||||
|
|||||||
@@ -43,6 +43,28 @@ angular
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sessionStorage.orgKeys = orgKeysb64;
|
||||||
|
};
|
||||||
|
|
||||||
|
_service.addOrgKey = function (orgKeyCt, privateKey) {
|
||||||
|
_orgKeys = _service.getOrgKeys();
|
||||||
|
if (!_orgKeys) {
|
||||||
|
_orgKeys = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
var orgKeysb64 = $sessionStorage.orgKeys;
|
||||||
|
if (!orgKeysb64) {
|
||||||
|
orgKeysb64 = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var orgKey = _service.rsaDecrypt(orgKeyCt.key, privateKey);
|
||||||
|
_orgKeys[orgKeyCt.id] = orgKey;
|
||||||
|
orgKeysb64[orgKeyCt.id] = forge.util.encode64(orgKey);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log('Cannot set org key. Decryption failed.');
|
||||||
|
}
|
||||||
|
|
||||||
$sessionStorage.orgKeys = orgKeysb64;
|
$sessionStorage.orgKeys = orgKeysb64;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
.module('bit.settings')
|
.module('bit.settings')
|
||||||
|
|
||||||
.controller('settingsCreateOrganizationController', function ($scope, $state, apiService, $uibModalInstance, cryptoService,
|
.controller('settingsCreateOrganizationController', function ($scope, $state, apiService, $uibModalInstance, cryptoService,
|
||||||
toastr, $analytics) {
|
toastr, $analytics, authService) {
|
||||||
$analytics.eventTrack('settingsCreateOrganizationController', { category: 'Modal' });
|
$analytics.eventTrack('settingsCreateOrganizationController', { category: 'Modal' });
|
||||||
|
|
||||||
$scope.model = {
|
$scope.model = {
|
||||||
@@ -16,10 +16,11 @@
|
|||||||
key: cryptoService.makeShareKey()
|
key: cryptoService.makeShareKey()
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.submitPromise = apiService.organizations.post(request, function () {
|
$scope.submitPromise = apiService.organizations.post(request, function (result) {
|
||||||
$uibModalInstance.dismiss('cancel');
|
$uibModalInstance.dismiss('cancel');
|
||||||
$analytics.eventTrack('Created Organization');
|
$analytics.eventTrack('Created Organization');
|
||||||
$state.go('backend.org.dashboard').then(function () {
|
authService.addProfileOrganization(result);
|
||||||
|
$state.go('backend.org.dashboard', { orgId: result.Id }).then(function () {
|
||||||
toastr.success('Your new organization is ready to go!', 'Organization Created');
|
toastr.success('Your new organization is ready to go!', 'Organization Created');
|
||||||
});
|
});
|
||||||
}).$promise;
|
}).$promise;
|
||||||
|
|||||||
Reference in New Issue
Block a user