organization signup

This commit is contained in:
Kyle Spearrin 2017-03-03 00:07:31 -05:00
parent 27495d5055
commit 880be03211
6 changed files with 59 additions and 19 deletions

View File

@ -29,11 +29,12 @@
del: { url: _apiUri + '/ciphers/:id/delete', method: 'POST', params: { id: '@id' } } del: { url: _apiUri + '/ciphers/:id/delete', method: 'POST', params: { id: '@id' } }
}); });
_service.shares = $resource(_apiUri + '/shares/:id', {}, { _service.organizations = $resource(_apiUri + '/organizations/:id', {}, {
get: { method: 'GET', params: { id: '@id' } }, get: { method: 'GET', params: { id: '@id' } },
listCipher: { url: _apiUri + '/shares/:cipherId', method: 'GET', params: { cipherId: '@cipherId' } }, list: { method: 'GET', params: {} },
post: { method: 'POST', params: {} }, post: { method: 'POST', params: {} },
del: { url: _apiUri + '/shares/:id/delete', method: 'POST', params: { id: '@id' } } put: { method: 'POST', params: { id: '@id' } },
del: { url: _apiUri + '/organizations/:id/delete', method: 'POST', params: { id: '@id' } }
}); });
_service.accounts = $resource(_apiUri + '/accounts', {}, { _service.accounts = $resource(_apiUri + '/accounts', {}, {

View File

@ -132,7 +132,7 @@ angular
}; };
_service.makeShareKey = function () { _service.makeShareKey = function () {
return forge.random.getBytesSync(32); return _service.rsaEncrypt(forge.random.getBytesSync(32));
}; };
_service.hashPassword = function (password, key) { _service.hashPassword = function (password, key) {

View File

@ -1,7 +1,7 @@
angular angular
.module('bit.settings') .module('bit.settings')
.controller('settingsController', function ($scope, $uibModal, apiService, toastr, authService) { .controller('settingsController', function ($scope, $state, $uibModal, apiService, toastr, authService) {
$scope.model = { $scope.model = {
profile: {}, profile: {},
twoFactorEnabled: false, twoFactorEnabled: false,
@ -70,6 +70,10 @@
}); });
}; };
$scope.viewOrganization = function (id) {
$state.go('backend.org.dashboard');
};
$scope.twoFactor = function () { $scope.twoFactor = function () {
var twoFactorModal = $uibModal.open({ var twoFactorModal = $uibModal.open({
animation: true, animation: true,

View File

@ -1,17 +1,27 @@
angular angular
.module('bit.settings') .module('bit.settings')
.controller('settingsCreateOrganizationController', function ($scope, apiService, $uibModalInstance, cryptoService, .controller('settingsCreateOrganizationController', function ($scope, $state, apiService, $uibModalInstance, cryptoService,
authService, toastr, $analytics) { toastr, $analytics) {
$analytics.eventTrack('settingsCreateOrganizationController', { category: 'Modal' }); $analytics.eventTrack('settingsCreateOrganizationController', { category: 'Modal' });
$scope.model = {
plan: 'Free'
};
$scope.submit = function (model) { $scope.submit = function (model) {
var request = { var request = {
masterPasswordHash: cryptoService.hashPassword(model.masterPassword) name: model.name,
planType: model.plan,
key: cryptoService.makeShareKey()
}; };
$scope.submitPromise = apiService.organizations.post(request, function () { $scope.submitPromise = apiService.organizations.post(request, function () {
$uibModalInstance.dismiss('cancel'); $uibModalInstance.dismiss('cancel');
$analytics.eventTrack('Created Organization'); $analytics.eventTrack('Created Organization');
$state.go('backend.org.dashboard').then(function () {
toastr.success('Your new organization is ready to go!', 'Organization Created');
});
}).$promise; }).$promise;
}; };

View File

@ -118,23 +118,26 @@
No organizations yet for your account. No organizations yet for your account.
</div> </div>
<div class="table-responsive" ng-show="model.organizations && model.organizations.length"> <div class="table-responsive" ng-show="model.organizations && model.organizations.length">
<table class="table table-striped table-hover"> <table class="table table-striped table-hover table-selectable">
<thead>
<tr>
<th style="width: 75px; min-width: 75px;"></th>
<th>Name</th>
</tr>
</thead>
<tbody> <tbody>
<tr ng-repeat="org in model.organizations | orderBy: ['name']"> <tr ng-repeat="org in model.organizations | orderBy: ['name']">
<td></td> <td class="actions" style="width: 40px; min-width: 40px;">
<td>{{org.Name}}</td> <button type="button" ng-click="viewOrganization(org.id)" class="btn btn-link btn-table"
uib-tooltip="View/Manage">
<i class="fa fa-lg fa-share"></i>
</button>
</td>
<td ng-click="viewOrganization(org.id)">
<span ng-click="$event.stopPropagation()">
{{org.name}}
</span>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<div class="box-footer" ng-show="!model.organizations || !model.organizations.length"> <div class="box-footer">
<button type="button" ng-click="createOrganization()" class="btn btn-default btn-flat"> <button type="button" ng-click="createOrganization()" class="btn btn-default btn-flat">
Create an Organization Create an Organization
</button> </button>

View File

@ -4,7 +4,6 @@
</div> </div>
<form name="createOrgForm" ng-submit="createOrgForm.$valid && submit(model)" api-form="submitPromise"> <form name="createOrgForm" ng-submit="createOrgForm.$valid && submit(model)" api-form="submitPromise">
<div class="modal-body"> <div class="modal-body">
<p>Create an organization.</p>
<div class="callout callout-danger validation-errors" ng-show="createOrgForm.$errors"> <div class="callout callout-danger validation-errors" ng-show="createOrgForm.$errors">
<h4>Errors have occured</h4> <h4>Errors have occured</h4>
<ul> <ul>
@ -16,6 +15,29 @@
<input type="text" id="name" name="Name" ng-model="model.name" class="form-control" <input type="text" id="name" name="Name" ng-model="model.name" class="form-control"
required api-field /> required api-field />
</div> </div>
<div class="form-group">
<div class="radio">
<label>
<input type="radio" ng-model="model.plan" name="PlanType" value="Free" checked>
Free
</label>
<p class="help-block">Share with 1 other user.</p>
</div>
<div class="radio">
<label>
<input type="radio" ng-model="model.plan" name="PlanType" value="Premium">
Premium ($1 /month)
</label>
<p class="help-block">Share with up to 5 users.</p>
</div>
<div class="radio">
<label>
<input type="radio" ng-model="model.plan" name="PlanType" value="Teams">
Teams ($2 /user per month)
</label>
<p class="help-block">Share with as many users as you need.</p>
</div>
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="createOrgForm.$loading"> <button type="submit" class="btn btn-primary btn-flat" ng-disabled="createOrgForm.$loading">