Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
fix for comment encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
talhasch committed Jun 9, 2018
1 parent f0a4822 commit 32c9920
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/directives/comment-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export default () => {
};

if ($scope.encrypt.val) {
const senderPrivateKey = cryptoService.decryptKey($rootScope.user.keys['memo']);
const receiverPublicKey = $scope.content.author_data.memo_key;
const senderPrivateKey = cryptoService.decryptKey($rootScope.user.keys['posting']);
const receiverPublicKey = $scope.content.author_data.posting.key_auths.pop()[0];

body = steem.memo.encode(senderPrivateKey, receiverPublicKey, `#${body}`);
}
Expand Down
17 changes: 11 additions & 6 deletions src/filters/comment-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ export default ($rootScope, cryptoService) => {
return comment.body;
}

const activeUser = $rootScope.user.username;
if (!activeUser) {
return comment.body;
}

// Parse json meta to check if its encrypted
let jsonMeta = {};
try {
Expand All @@ -24,6 +19,11 @@ export default ($rootScope, cryptoService) => {
return comment.body;
}

const activeUser = $rootScope.user ? $rootScope.user.username : null;
if (!activeUser) {
return '*encrypted comment*'
}

// Only comment's owner and parent comment/post's owner can see
if (![comment.author, comment.parent_author].includes(activeUser)) {
return '*encrypted comment*'
Expand All @@ -34,10 +34,15 @@ export default ($rootScope, cryptoService) => {
return '*encrypted comment. use traditional login to see comment.*'
}

// Private posting key required
if(!$rootScope.user.keys.posting){
return '*encrypted comment. posting private key required to see this comment.*'
}

// Get user private memo key
let privateMemoKey = null;
try {
privateMemoKey = cryptoService.decryptKey($rootScope.user.keys['memo']);
privateMemoKey = cryptoService.decryptKey($rootScope.user.keys['posting']);
} catch (e) {
return '*encrypted comment*'
}
Expand Down

0 comments on commit 32c9920

Please sign in to comment.