mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-31 08:20:37 +01:00
add new org to profile
This commit is contained in:
parent
1cbd322105
commit
0acab61f2e
@ -80,6 +80,26 @@ angular
|
||||
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) {
|
||||
_userProfile.extended = {
|
||||
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;
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
.module('bit.settings')
|
||||
|
||||
.controller('settingsCreateOrganizationController', function ($scope, $state, apiService, $uibModalInstance, cryptoService,
|
||||
toastr, $analytics) {
|
||||
toastr, $analytics, authService) {
|
||||
$analytics.eventTrack('settingsCreateOrganizationController', { category: 'Modal' });
|
||||
|
||||
$scope.model = {
|
||||
@ -16,10 +16,11 @@
|
||||
key: cryptoService.makeShareKey()
|
||||
};
|
||||
|
||||
$scope.submitPromise = apiService.organizations.post(request, function () {
|
||||
$scope.submitPromise = apiService.organizations.post(request, function (result) {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
$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');
|
||||
});
|
||||
}).$promise;
|
||||
|
Loading…
Reference in New Issue
Block a user