1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-31 08:20:37 +01:00

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' } }
});
_service.shares = $resource(_apiUri + '/shares/:id', {}, {
_service.organizations = $resource(_apiUri + '/organizations/: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: {} },
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', {}, {

View File

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

View File

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

View File

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

View File

@ -118,23 +118,26 @@
No organizations yet for your account.
</div>
<div class="table-responsive" ng-show="model.organizations && model.organizations.length">
<table class="table table-striped table-hover">
<thead>
<tr>
<th style="width: 75px; min-width: 75px;"></th>
<th>Name</th>
</tr>
</thead>
<table class="table table-striped table-hover table-selectable">
<tbody>
<tr ng-repeat="org in model.organizations | orderBy: ['name']">
<td></td>
<td>{{org.Name}}</td>
<td class="actions" style="width: 40px; min-width: 40px;">
<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>
</tbody>
</table>
</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">
Create an Organization
</button>

View File

@ -4,7 +4,6 @@
</div>
<form name="createOrgForm" ng-submit="createOrgForm.$valid && submit(model)" api-form="submitPromise">
<div class="modal-body">
<p>Create an organization.</p>
<div class="callout callout-danger validation-errors" ng-show="createOrgForm.$errors">
<h4>Errors have occured</h4>
<ul>
@ -16,6 +15,29 @@
<input type="text" id="name" name="Name" ng-model="model.name" class="form-control"
required api-field />
</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 class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="createOrgForm.$loading">