mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 00:10:20 +00:00
Continue security
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
<script src="js/rzslider.min.js"></script>
|
||||
<script src="js/ngDialog.min.js"></script>
|
||||
<script src="js/angular-scrollable-table.min.js"></script>
|
||||
<script src="js/angular-zxcvbn.min.js"></script>
|
||||
<script src="js/zxcvbn.js"></script>
|
||||
<script src="scripts/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -79,7 +79,7 @@ String.prototype.replaceAll = function (search, replace)
|
||||
};
|
||||
|
||||
|
||||
app.service ('bridgeService', function ($http, $window, ngToast) {
|
||||
app.service ('bridgeService', function ($http, $window, ngToast, zxcvbn) {
|
||||
var self = this;
|
||||
this.state = {base: "./api/devices", bridgelocation: ".", systemsbase: "./system", huebase: "./api", configs: [], backups: [], devices: [], device: {},
|
||||
mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false,
|
||||
@@ -227,6 +227,11 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
||||
);
|
||||
};
|
||||
|
||||
this.score = function() {
|
||||
var compute = zxcvbn.apply(null, arguments);
|
||||
return compute && compute.score;
|
||||
}
|
||||
|
||||
this.aContainsB = function (a, b) {
|
||||
return a.indexOf(b) >= 0;
|
||||
}
|
||||
@@ -1189,7 +1194,7 @@ app.controller('SecurityDialogCtrl', function ($scope, bridgeService, ngDialog)
|
||||
|
||||
$scope.setSecurityInfo = function () {
|
||||
ngDialog.close('ngdialog1');
|
||||
bridgeService.changeSecuritySettings($scope.useLinkButton, $scope.secureHueApi, $scope.execGarden, $scope.aPassword, $scope.aPassword2);
|
||||
bridgeService.changeSecuritySettings($scope.useLinkButton, $scope.secureHueApi, $scope.execGarden, $scope.password, $scope.password2);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -3015,7 +3020,7 @@ app.filter('passwordCount', [function() {
|
||||
};
|
||||
}]);
|
||||
|
||||
app.directive('okPassword', ['zxcvbn', function(zxcvbn) {
|
||||
app.directive('okPassword', ['bridgeService', function(bridgeService) {
|
||||
return {
|
||||
// restrict to only attribute and class
|
||||
restrict: 'AC',
|
||||
@@ -3031,7 +3036,7 @@ app.directive('okPassword', ['zxcvbn', function(zxcvbn) {
|
||||
var pwd = $scope.password = $element.val();
|
||||
|
||||
// resolve password strength score using zxcvbn service
|
||||
$scope.passwordStrength = pwd ? (pwd.length > 7 && zxcvbn.score(pwd) || 0) : null;
|
||||
$scope.passwordStrength = pwd ? (pwd.length > 7 && bridgeService.score(pwd) || 0) : null;
|
||||
|
||||
// define the validity criterion for okPassword constraint
|
||||
ngModelCtrl.$setValidity('okPassword', $scope.passwordStrength >= 2);
|
||||
@@ -3042,14 +3047,6 @@ app.directive('okPassword', ['zxcvbn', function(zxcvbn) {
|
||||
}]);
|
||||
|
||||
app.controller('FormController', function($scope) {});
|
||||
app.factory('zxcvbn', [function() {
|
||||
return {
|
||||
score: function() {
|
||||
var compute = zxcvbn.apply(null, arguments);
|
||||
return compute && compute.score;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
app.directive('pwCheck', [function () {
|
||||
return {
|
||||
|
||||
@@ -541,7 +541,7 @@
|
||||
<label>Change Password</label>
|
||||
<div class="form-hint">If you are exposing this to the internet, you use a sufficiently strong password. Password must be more than 7 characters.</div>
|
||||
|
||||
<input type="password" class="form-control ok-password" ng-class="(securityForm.password.$dirty && securityForm.password.$invalid) ? 'error' : ''" id="password" name="password" placeholder="Enter Password" ng-required="true" ng-model="aPassword">
|
||||
<input type="password" class="form-control ok-password" ng-class="(securityForm.password.$dirty && securityForm.password.$invalid) ? 'error' : ''" id="password" name="password" placeholder="Enter Password" ng-required="true" ng-model="password">
|
||||
|
||||
<div class="label password-count" ng-class="password.length > 7 ? 'label-success' : 'label-danger'" ng-cloak>{{ password | passwordCount:7 }}</div>
|
||||
|
||||
@@ -551,7 +551,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Confirm Password</label>
|
||||
<input id="password-2" class="form-control" type="password" ng-model="aPassword2" ng-required="true" pw-check="aPassword" />
|
||||
<input id="password-2" class="form-control" type="password" ng-model="password2" ng-required="true" pw-check="password" />
|
||||
<div class="msg-block" ng-show="securityForm.$error">
|
||||
<span class="msg-error" ng-show="securityForm.pw2.$error.pwmatch">Passwords don't match.</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user