Notification link working (Onclick goes to credential)

This commit is contained in:
brantje 2016-09-23 17:22:47 +02:00
parent 0fd24a5002
commit cbd8406854
5 changed files with 20 additions and 4 deletions

View file

@ -79,7 +79,8 @@ class CredentialController extends ApiController {
* @NoAdminRequired
*/
public function getCredential($credential_id) {
return;
//@TODO check user
return new JSONResponse($this->credentialService->getCredentialById($credential_id));
}
/**
@ -153,6 +154,7 @@ class CredentialController extends ApiController {
return;
}
/**
* @NoAdminRequired
*/

View file

@ -65,7 +65,9 @@ angular.module('passmanApp')
var storedCredential = SettingsService.getSetting('edit_credential');
if (!storedCredential) {
$location.path('/vault/' + $routeParams.vault_id);
CredentialService.getCredential($routeParams.credential_id).then(function(result){
$scope.storedCredential = CredentialService.decryptCredential(angular.copy(result));
});
} else {
$scope.storedCredential = CredentialService.decryptCredential(angular.copy(storedCredential));
$scope.storedCredential.password_repeat = angular.copy($scope.storedCredential.password);

View file

@ -75,6 +75,16 @@ angular.module('passmanApp')
}
});
},
getCredential: function(id){
var queryUrl = OC.generateUrl('apps/passman/api/v2/credentials/' + id);
return $http.get(queryUrl).then(function (response) {
if (response.data) {
return response.data;
} else {
return response;
}
});
},
encryptCredential: function (credential) {
for (var i = 0; i < _encryptedFields.length; i++) {
var field = _encryptedFields[i];

View file

@ -38,7 +38,7 @@ class Notifier implements INotifier {
// Deal with known subjects
case 'credential_expired':
$notification->setParsedSubject(
(string) $l->t('Your credential "%s" expired', $notification->getSubjectParameters())
(string) $l->t('Your credential "%s" expired, click here to update the credential.', $notification->getSubjectParameters())
);
// Deal with the actions for a known subject

View file

@ -26,6 +26,8 @@ class NotificationService {
}
function credentialExpiredNotification($credential){
$urlGenerator = \OC::$server->getURLGenerator();
$link = $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('','index.php/apps/passman/#/vault/'. $credential->getVaultId() .'/edit/'. $credential->getId()));
$notification = $this->manager->createNotification();
$acceptAction = $notification->createAction();
$acceptAction->setLabel('change')
@ -40,7 +42,7 @@ class NotificationService {
->setDateTime(new \DateTime())
->setObject('credential', $credential->getId()) // $type and $id
->setSubject('credential_expired', [$credential->getLabel()]) // $subject and $parameters
->setLink('/apps/passman/#/vault/'. $credential->getVaultId() .'/edit/'. $credential->getId())
->setLink($link)
->addAction($acceptAction)
->addAction($declineAction);