Add passman version to settings

This commit is contained in:
brantje 2016-09-24 20:47:47 +02:00
parent 83cdb0c953
commit c1a2e959ef
5 changed files with 109 additions and 79 deletions

View file

@ -50,6 +50,7 @@ return [
//Internal API
['name' => 'internal#remind', 'url' => '/api/internal/notifications/remind/{credential_id}', 'verb' => 'POST'],
['name' => 'internal#read', 'url' => '/api/internal/notifications/read/{credential_id}', 'verb' => 'DELETE'],
['name' => 'internal#getAppVersion', 'url' => '/api/internal/version', 'verb' => 'GET'],
]
];

View file

@ -15,22 +15,27 @@ use OCP\IRequest;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\ApiController;
use OCA\Passman\Service\CredentialService;
use \OC_App;
class InternalController extends ApiController {
private $userId;
private $credentialService;
public function __construct($AppName,
IRequest $request,
$UserId,
CredentialService $credentialService){
CredentialService $credentialService) {
parent::__construct($AppName, $request);
$this->userId = $UserId;
$this->credentialService = $credentialService;
}
function remind($credential_id){
/**
* @NoAdminRequired
*/
public function remind($credential_id) {
$credential = $this->credentialService->getCredentialById($credential_id, $this->userId);
$credential->setExpireTime(time()+ (24 * 60 * 60));
$credential->setExpireTime(time() + (24 * 60 * 60));
$this->credentialService->upd($credential);
$manager = \OC::$server->getNotificationManager();
@ -41,7 +46,10 @@ class InternalController extends ApiController {
$manager->markProcessed($notification);
}
function read($credential_id){
/**
* @NoAdminRequired
*/
public function read($credential_id) {
$credential = $this->credentialService->getCredentialById($credential_id, $this->userId);
$credential->setExpireTime(0);
@ -54,4 +62,12 @@ class InternalController extends ApiController {
->setUser($this->userId);
$manager->markProcessed($notification);
}
/**
* @NoAdminRequired
*/
public function getAppVersion() {
return new JSONResponse(array('version' => OC_App::getAppVersion('passman')));
}
}

View file

@ -8,90 +8,99 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams) {
.controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http',
function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http) {
$scope.tabs = [{
title: 'General settings',
url: 'views/partials/forms/settings/general_settings.html'
}, {
title: 'Password Tool',
url: 'views/partials/forms/settings/tool.html'
$scope.tabs = [{
title: 'General settings',
url: 'views/partials/forms/settings/general_settings.html'
}, {
title: 'Password Tool',
url: 'views/partials/forms/settings/tool.html'
},
{
title: 'Import credentials',
url: 'views/partials/forms/settings/import.html'
},
{
title: 'Import credentials',
url: 'views/partials/forms/settings/import.html'
},
{
title: 'Export credentials',
url: 'views/partials/forms/settings/export.html'
},
{
title: 'Export credentials',
url: 'views/partials/forms/settings/export.html'
}];
}];
$scope.currentTab = $scope.tabs[0];
$scope.currentTab = $scope.tabs[0];
$scope.onClickTab = function (tab) {
$scope.currentTab = tab;
};
$scope.onClickTab = function (tab) {
$scope.currentTab = tab;
};
$scope.isActiveTab = function (tab) {
return tab.url == $scope.currentTab.url;
};
$scope.isActiveTab = function (tab) {
return tab.url == $scope.currentTab.url;
};
$scope.$watch(function () {
return VaultService.getActiveVault()
}, function (vault) {
$scope.active_vault = vault;
});
var getPassmanVersion = function () {
var url = OC.generateUrl('apps/passman/api/internal/version');
$http.get(url).then(function(result){
$scope.passman_version = result.data.version;
})
};
getPassmanVersion();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
$location.path('/')
}
} else {
if (SettingsService.getSetting('defaultVault') && SettingsService.getSetting('defaultVaultPass')) {
var _vault = angular.copy(SettingsService.getSetting('defaultVault'));
_vault.vaultKey = angular.copy(SettingsService.getSetting('defaultVaultPass'));
VaultService.setActiveVault(_vault);
$scope.active_vault = _vault;
}
}
if ($scope.active_vault) {
$scope.$parent.selectedVault = true;
}
$rootScope.$on('logout', function () {
$scope.selectedVault = false;
});
$scope.startScan = function(minStrength){
VaultService.getVault($scope.active_vault).then(function(credentials){
var results = [];
for(var i = 0; i < credentials.length; i++){
var c = CredentialService.decryptCredential(angular.copy(credentials[i]));
if(c.password && c.password.length > 0 && c.hidden == 0) {
var zxcvbn_result = zxcvbn(c.password);
if(zxcvbn_result.score <= minStrength){
results.push({
credential_id: c.credential_id,
label: c.label,
password: c.password,
password_zxcvbn_result: zxcvbn_result
});
}
}
//@todo loop custom fields (if any and check secret fields
}
$scope.scan_result = results;
$scope.$watch(function () {
return VaultService.getActiveVault()
}, function (vault) {
$scope.active_vault = vault;
});
};
$scope.cancel = function () {
$location.path('/vault/' + $routeParams.vault_id);
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
$location.path('/')
}
} else {
if (SettingsService.getSetting('defaultVault') && SettingsService.getSetting('defaultVaultPass')) {
var _vault = angular.copy(SettingsService.getSetting('defaultVault'));
_vault.vaultKey = angular.copy(SettingsService.getSetting('defaultVaultPass'));
VaultService.setActiveVault(_vault);
$scope.active_vault = _vault;
};
}
}
if ($scope.active_vault) {
$scope.$parent.selectedVault = true;
}
}]);
$rootScope.$on('logout', function () {
$scope.selectedVault = false;
});
$scope.startScan = function (minStrength) {
VaultService.getVault($scope.active_vault).then(function (credentials) {
var results = [];
for (var i = 0; i < credentials.length; i++) {
var c = CredentialService.decryptCredential(angular.copy(credentials[i]));
if (c.password && c.password.length > 0 && c.hidden == 0) {
var zxcvbn_result = zxcvbn(c.password);
if (zxcvbn_result.score <= minStrength) {
results.push({
credential_id: c.credential_id,
label: c.label,
password: c.password,
password_zxcvbn_result: zxcvbn_result
});
}
}
//@todo loop custom fields (if any and check secret fields
}
$scope.scan_result = results;
});
};
$scope.cancel = function () {
$location.path('/vault/' + $routeParams.vault_id);
};
}]);

View file

@ -51,7 +51,7 @@ angular.module('views/partials/forms/settings/export.html', []).run(['$templateC
angular.module('views/partials/forms/settings/general_settings.html', []).run(['$templateCache', function($templateCache) {
'use strict';
$templateCache.put('views/partials/forms/settings/general_settings.html',
'<div class="row"><div class="col-xs-12 col-md-6"><h3>Change vault key</h3><label>Old vault password</label><input type="password" ng-model="oldVaultPass"><label>New vault password</label><password-gen ng-model="newVaultPass"></password-gen><ng-password-meter password="newVaultPass"></ng-password-meter><label>New vault password</label><input type="password" ng-model="newVaultPass2"> <button ng-click="changeVaultPassword(oldVaultPass,newVaultPass,newVaultPass2)" tooltip="\'Not working :P\'">Change</button></div><div class="col-xs-12 col-md-6"></div></div>');
'<div class="row"><div class="col-xs-12 col-md-6"><h3>Change vault key</h3><label>Old vault password</label><input type="password" ng-model="oldVaultPass"><label>New vault password</label><password-gen ng-model="newVaultPass"></password-gen><ng-password-meter password="newVaultPass"></ng-password-meter><label>New vault password</label><input type="password" ng-model="newVaultPass2"> <button ng-click="changeVaultPassword(oldVaultPass,newVaultPass,newVaultPass2)" tooltip="\'Not working :P\'">Change</button></div><div class="col-xs-12 col-md-6"><h3>About passman</h3><p>Version: <b>{{passman_version}}</b><br>Bla bla about passman, our vision, and donate link.</p></div></div>');
}]);
angular.module('views/partials/forms/settings/import.html', []).run(['$templateCache', function($templateCache) {

View file

@ -12,6 +12,10 @@
<button ng-click="changeVaultPassword(oldVaultPass,newVaultPass,newVaultPass2)" tooltip="'Not working :P'">Change</button>
</div>
<div class="col-xs-12 col-md-6">
<h3>About passman</h3>
<p>
Version: <b>{{passman_version}}</b><br />
Bla bla about passman, our vision, and donate link.
</p>
</div>
</div>