Skip to content

Commit

Permalink
#62: improve enter key password pop-up menu messages and size
Browse files Browse the repository at this point in the history
  • Loading branch information
zubaidullo committed Apr 7, 2018
1 parent ed98030 commit 8da25d5
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/lib/controller/pwd.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ define(function(require, exports, module) {
that.options.beforePasswordRequest();
}
if (that.options.openPopup) {
that.porto.windows.openPopup('common/ui/modal/_popup-enter-key-password.html?id=' + that.id, {width: 470, height: 327, modal: false}, function(window) {
that.porto.windows.openPopup('common/ui/modal/_popup-enter-key-password.html?id=' + that.id, {width: 470, height: 355, modal: false}, function(window) {
that.pwdPopup = window;
});
}
Expand Down
5 changes: 5 additions & 0 deletions common/lib/pgpModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ define(function(require, exports, module) {
* @return {Promise<String>}
*/
function signMessage(message, signKey) {
console.log("-------------------------");
console.log("sign message");
console.log(message);
console.log(signKey);
console.log("-------------------------");
return openpgp.getWorker().signClearMessage([signKey], message);
}

Expand Down
14 changes: 10 additions & 4 deletions common/ui/inline/encryptFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ porto.EncryptFrame = function(prefs) {
};

porto.EncryptFrame.prototype.attachTo = function(element, options) {
console.log("encryptFrame.js - prototype.attachTo");
console.log("Element: %s", element);
console.log("Options: %s", options);

$.extend(this._options, options);
this._init(element);
this._establishConnection();
Expand Down Expand Up @@ -389,13 +393,14 @@ porto.EncryptFrame.prototype._getEmailRecipient = function() {
* @param {string} msg txt or html content
*/
porto.EncryptFrame.prototype._setMessage = function(msg, type, fingerprint) {
console.log("encryptFrame -> prototype._setMessage");
if (this._emailTextElement.is('textarea')) {
// decode HTML entities for type text due to previous HTML parsing
msg = porto.util.decodeHTML(msg);
this._emailTextElement.val(msg);
$(this._emailTextElement).text(msg);
//console.log(msg);
//this._emailTextElement.removeClass('bp-set-pub-key');
// console.log(msg);
// this._emailTextElement.removeClass('bp-set-pub-key');

var signTargets = document.getElementsByClassName('bp-sign-target');
if (signTargets.length > 0) {
Expand All @@ -404,7 +409,7 @@ porto.EncryptFrame.prototype._setMessage = function(msg, type, fingerprint) {
signTargets[0].dispatchEvent(changeEvent);
}
catch (err) {
//console.error(err);
console.error(err);
}
}
$(this._emailTextElement).removeClass('bp-sign-target');
Expand Down Expand Up @@ -451,8 +456,9 @@ porto.EncryptFrame.prototype._resetEmailText = function() {

porto.EncryptFrame.prototype._registerEventListener = function() {
var that = this;
console.log(that);
this._port.onMessage.addListener(function(msg) {
//console.log('eFrame-%s event %s received', that.id, msg.event);
console.log('E-Frame | Event - [%s] ', msg.event);
switch (msg.event) {
case 'encrypt-dialog-cancel':
case 'sign-dialog-cancel':
Expand Down
22 changes: 21 additions & 1 deletion common/ui/inline/main-cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ porto.util.csGetHash().then(function(hash) {
porto.main.port = null;

porto.main.connect = function() {
console.log("main-cs.js -> connect");
if (document.portoControl) {
return;
}
Expand Down Expand Up @@ -56,6 +57,7 @@ porto.main.off = function() {
};

porto.main.scanLoop = function() {
console.log("[ SCAN ]");
// find armored PGP text
var pgpTag = porto.main.findPGPTag(porto.main.regex);
if (pgpTag.length !== 0) {
Expand All @@ -64,6 +66,8 @@ porto.main.scanLoop = function() {
// find editable content
var editable = porto.main.findEditable();
if (editable.length !== 0) {
console.log("SCAN -> found editable content");
console.log(editable);
porto.main.attachEncryptFrame(editable);
}
};
Expand Down Expand Up @@ -179,6 +183,8 @@ porto.main.getMessageType = function(armored) {
};

porto.main.attachExtractFrame = function(element) {
console.log("main-cs.js -> attachExtractFrame");

// check status of PGP tags
var newObj = element.filter(function() {
return !porto.ExtractFrame.isAttached($(this).parent());
Expand Down Expand Up @@ -213,9 +219,15 @@ porto.main.attachExtractFrame = function(element) {
* @param {boolean} expanded state of frame
*/
porto.main.attachEncryptFrame = function(element, expanded) {
console.log("main-cs.js -> attachEncryptFrame");

console.log(element);
console.log(expanded);
// check status of elements
//TODO expanded is sometimes UNDEFINED
var newObj = element.filter(function() {
if (expanded) {
console.log("expanded");
// filter out only attached frames
if (element.data(porto.FRAME_STATUS) === porto.FRAME_ATTACHED) {
// trigger expand state of attached frames
Expand All @@ -225,15 +237,20 @@ porto.main.attachEncryptFrame = function(element, expanded) {
return true;
}
} else {
console.log("not expanded");
// filter out attached and detached frames
return !porto.EncryptFrame.isAttached($(this));
}
});
console.log("next");
// create new encrypt frames for new discovered editable fields
newObj.each(function(index, element) {
console.log("newObj -> each");
new porto.EncryptFrame(porto.main.prefs).then(function(frame) {
var eFrame = frame;
console.log(element);
if ($(element).hasClass('bp-sign-target')) {
console.log("main-cs.js -> attachEncryptFrame -> has class bp-sign-target");
eFrame.attachTo($(element), {
expanded: expanded,
su_fingerprint: getCookie('su_fingerprint'),
Expand Down Expand Up @@ -277,9 +294,10 @@ function getCookie(cname) {
}

porto.main.addMessageListener = function() {
console.log("main-cs.js -> addMessageListener");
porto.main.port.onMessage.addListener(
function(request) {
//console.log('contentscript: %s onRequest: %o', document.location.toString(), request);
console.log('contentscript: %s onRequest: %o', document.location.toString(), request);
if (request.event === undefined) {
return;
}
Expand All @@ -296,6 +314,8 @@ porto.main.addMessageListener = function() {
break;
case 'context-encrypt':
if (porto.main.contextTarget !== null) {
console.log("main-cs.js -> addMessageListener -> context-encrypt");

porto.main.attachEncryptFrame(porto.main.contextTarget, true);
porto.main.contextTarget = null;
}
Expand Down
2 changes: 1 addition & 1 deletion common/ui/modal/_popup-enter-key-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="b-popup-body_white-bg g-padding">
<h6 class="b-form-label_h2" style="font-size: 10px"><span id="userId"></span> - <span
id="keyId"></span></h6>
<label class="b-form-label">Enter key password to sign this message</label>
<label class="b-form-label">To sign with your key, provide the password.</label>
<input type="password" class="b-form-input b-form-input_full" id="password">
<span class="label label-danger hide noUi-marker-normal b-form-hint b-form-hint_red" data-l10n-id="pwd_dialog_wrong_pwd"></span>

Expand Down
2 changes: 1 addition & 1 deletion locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"description": "Title of the password dialog."
},
"pwd_dialog_header": {
"message": "Enter key password",
"message": "The key you're using is password protected by the Subutai E2E plugin",
"description": "Header of the password dialog."
},
"pwd_dialog_userid": {
Expand Down

0 comments on commit 8da25d5

Please sign in to comment.