Merge pull request #3490 from LacunaSoftware/confirm-passwords

Require confirmation of UI password when updating it
This commit is contained in:
Kenneth Skovhede
2018-11-14 08:25:03 +01:00
committed by GitHub
2 changed files with 14 additions and 7 deletions
@@ -1,4 +1,4 @@
backupApp.controller('SystemSettingsController', function($rootScope, $scope, $location, $cookies, AppService, AppUtils, SystemInfo, gettextCatalog) {
backupApp.controller('SystemSettingsController', function($rootScope, $scope, $location, $cookies, AppService, DialogService, AppUtils, SystemInfo, gettextCatalog) {
$scope.SystemInfo = SystemInfo.watch($scope);
$scope.theme = $scope.$parent.$parent.saved_theme;
@@ -53,6 +53,7 @@ backupApp.controller('SystemSettingsController', function($rootScope, $scope, $l
$scope.requireRemotePassword = data.data['server-passphrase'] != null && data.data['server-passphrase'] != '';
$scope.remotePassword = data.data['server-passphrase'];
$scope.confirmPassword = '';
$scope.allowRemoteAccess = data.data['server-listen-interface'] != 'loopback';
$scope.startupDelayDurationValue = data.data['startup-delay'].substr(0, data.data['startup-delay'].length - 1) == "" ? "0" : data.data['startup-delay'].substr(0, data.data['startup-delay'].length - 1);
$scope.startupDelayDurationMultiplier = data.data['startup-delay'].substr(-1) == "" ? "s" : data.data['startup-delay'].substr(-1);
@@ -84,12 +85,14 @@ backupApp.controller('SystemSettingsController', function($rootScope, $scope, $l
'disable-tray-icon-login': $scope.disableTrayIconLogin
};
if ($scope.requireRemotePassword) {
if ($scope.rawdata['server-passphrase'] != $scope.remotePassword) {
patchdata['server-passphrase-salt'] = CryptoJS.lib.WordArray.random(256/8).toString(CryptoJS.enc.Base64);
patchdata['server-passphrase'] = CryptoJS.SHA256(CryptoJS.enc.Hex.parse(CryptoJS.enc.Utf8.parse($scope.remotePassword) + CryptoJS.enc.Base64.parse(patchdata['server-passphrase-salt']))).toString(CryptoJS.enc.Base64);
if ($scope.requireRemotePassword && $scope.rawdata['server-passphrase'] != $scope.remotePassword) {
if ($scope.remotePassword != $scope.confirmPassword) {
AppUtils.notifyInputError(gettextCatalog.getString('The passwords do not match'));
return;
}
} else {
patchdata['server-passphrase-salt'] = CryptoJS.lib.WordArray.random(256/8).toString(CryptoJS.enc.Base64);
patchdata['server-passphrase'] = CryptoJS.SHA256(CryptoJS.enc.Hex.parse(CryptoJS.enc.Utf8.parse($scope.remotePassword) + CryptoJS.enc.Base64.parse(patchdata['server-passphrase-salt']))).toString(CryptoJS.enc.Base64);
} else if (!$scope.requireRemotePassword) {
patchdata['server-passphrase-salt'] = null;
patchdata['server-passphrase'] = null;
}
@@ -5,9 +5,13 @@
<h2 translate>Access to user interface</h2>
<div class="input mixed multiple">
<input type="checkbox" class="checkbox" id="hasPassword" name="hasPassword" ng-model="requireRemotePassword" />
<label for="password" translate>Password</label>
<label for="password" translate>Password</label><br>
<input type="password" id="password" name="password" ng-model="remotePassword" />
</div>
<div class="input mixed multiple">
<label for="confirm-password" translate>Confirm password</label><br>
<input type="password" id="confirm-password" name="confirm-password" ng-model="confirmPassword" autocomplete="new-password" />
</div>
<div class="input checkbox">
<input type="checkbox" class="checkbox" id="remote" name="remote" ng-model="allowRemoteAccess" />
<label for="remote" translate>Allow remote access (requires restart)</label>