1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

Generate andcopy passwords. Save password options

This commit is contained in:
Kyle Spearrin
2016-09-17 22:57:51 -04:00
parent 4105d2b5ad
commit 350d671c26
8 changed files with 145 additions and 28 deletions

View File

@@ -89,7 +89,7 @@
templateUrl: 'app/vault/views/vaultAddSite.html',
controller: 'vaultAddSiteController',
data: { authorize: true },
params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null }
params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null, site: null }
})
.state('editSite', {
url: '/edit-site?siteId',
@@ -104,7 +104,7 @@
templateUrl: 'app/tools/views/toolsPasswordGenerator.html',
controller: 'toolsPasswordGeneratorController',
data: { authorize: true },
params: { animation: null, fromAdd: false, fromEdit: null }
params: { animation: null, addState: null, editState: null }
});
})
.run(function ($rootScope, userService, loginService, tokenService, $state) {

View File

@@ -1,2 +1,2 @@
angular
.module('bit.tools', []);
.module('bit.tools', ['ngAnimate', 'ngclipboard', 'toastr']);

View File

@@ -1,6 +1,63 @@
angular
.module('bit.tools')
.controller('toolsPasswordGeneratorController', function ($scope, $state, $stateParams) {
.controller('toolsPasswordGeneratorController', function ($scope, $state, $stateParams, passwordGenerationService, toastr, $q) {
var addState = $stateParams.addState,
editState = $stateParams.editState;
popupUtils.initListSectionItemListeners();
$scope.password = '-';
$q.when(passwordGenerationService.getOptions()).then(function (options) {
$scope.options = options;
$scope.regenerate();
});
$scope.regenerate = function () {
$scope.password = passwordGenerationService.generatePassword($scope.options);
};
$scope.saveOptions = function (options) {
if (!options.uppercase && !options.lowercase && !options.number && !options.special) {
options.lowercase = $scope.options.lowercase = true;
}
if (!options.minNumber) {
options.minNumber = $scope.options.minNumber = 0;
}
if (!options.minSpecial) {
options.minSpecial = $scope.options.minSpecial = 0;
}
passwordGenerationService.saveOptions(options);
$scope.regenerate();
};
$scope.clipboardError = function (e, password) {
toastr.info('Your web browser does not support easy clipboard copying. Copy it manually instead.');
};
$scope.clipboardSuccess = function (e) {
e.clearSelection();
toastr.info('Password copied!');
};
$scope.close = function () {
if (addState) {
$state.go('addSite', {
animation: 'out-slide-down',
site: addState
});
}
else if (editState) {
$state.go('editSite', {
animation: 'out-slide-down',
siteId: editState
});
}
else {
$state.go('tabs.tools', {
animation: 'out-slide-down'
});
}
};
});

View File

@@ -9,15 +9,16 @@
</div>
<div class="content">
<div style="margin: 20px; font-size: 20px; text-align: center;">
<span id="generated-password">*&Houhdasdy87</span>
<span id="generated-password">{{password}}</span>
</div>
<div class="list" style="margin-top: 0;">
<div class="list-section" style="padding-top: 0;">
<div class="list-section-items">
<a class="list-section-item" href="#">
<a class="list-section-item text-primary" href="" ng-click="regenerate()">
Regenerate Password
</a>
<a class="list-section-item" href="#">
<a class="list-section-item text-primary" href="" ngclipboard ngclipboard-error="clipboardError(e)"
ngclipboard-success="clipboardSuccess(e)" data-clipboard-target="#generated-password">
Copy Password
</a>
</div>
@@ -32,19 +33,19 @@
</div>
<div class="list-section-item list-section-item-checkbox">
<label for="uppercase">A-Z</label>
<input id="uppercase" type="checkbox">
<input id="uppercase" type="checkbox" ng-model="options.uppercase" ng-change="saveOptions(options)">
</div>
<div class="list-section-item list-section-item-checkbox">
<label for="lowercase">a-z</label>
<input id="lowercase" type="checkbox">
<input id="lowercase" type="checkbox" ng-model="options.lowercase" ng-change="saveOptions(options)">
</div>
<div class="list-section-item list-section-item-checkbox">
<label for="numbers">0-9</label>
<input id="numbers" type="checkbox">
<input id="numbers" type="checkbox" ng-model="options.number" ng-change="saveOptions(options)">
</div>
<div class="list-section-item list-section-item-checkbox">
<label for="special">!@#$%^&*</label>
<input id="special" type="checkbox">
<input id="special" type="checkbox" ng-model="options.special" ng-change="saveOptions(options)">
</div>
</div>
</div>
@@ -52,11 +53,11 @@
<div class="list-section-items">
<div class="list-section-item list-section-item-input">
<label for="min-numbers">Minimum Numbers</label>
<input id="min-numbers" type="number" min="0" max="5">
<input id="min-numbers" type="number" min="0" max="5" ng-model="options.minNumber" ng-change="saveOptions(options)">
</div>
<div class="list-section-item list-section-item-input">
<label for="min-special">Minimum Special</label>
<input id="min-special" type="number" min="0" max="5">
<input id="min-special" type="number" min="0" max="5" ng-model="options.minSpecial" ng-change="saveOptions(options)">
</div>
</div>
</div>
@@ -64,7 +65,7 @@
<div class="list-section-items">
<div class="list-section-item list-section-item-checkbox">
<label for="ambiguous">Avoid Ambiguous Characters</label>
<input id="ambiguous" type="checkbox">
<input id="ambiguous" type="checkbox" ng-model="options.ambiguous" ng-change="saveOptions(options)">
</div>
</div>
</div>

View File

@@ -200,6 +200,10 @@
position: relative;
z-index: 1;
&.text-primary {
color: @brand-primary !important;
}
&:not(.wrap) {
white-space: nowrap;
overflow: hidden;

View File

@@ -24,6 +24,9 @@
}
else if (checkbox.length > 0) {
checkbox.prop('checked', !checkbox.is(':checked'));
if (angular) {
angular.element(checkbox[0]).triggerHandler('click');
}
}
else if (select.length > 0) {
select.openSelect();