Skip to content

Commit cc97729

Browse files
committed
Merge pull request #76 in CCKEY/frontend from bugfix/CCKEY-271-queue-button-doesn-t-check-for to master
* commit '919c87e0ef1781d77f2249539d78ee9194646dbd': CCKEY-271 Added check for private key
2 parents ddc1867 + 919c87e commit cc97729

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/BaseLayout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class BaseLayout extends React.Component {
279279
<Layout.Header className="cckey-base-layout-header">
280280
<Row type="flex" justify="end" align="bottom">
281281
{
282-
this.props.encryptionJobStore.jobNotice &&
282+
this.props.encryptionJobStore.jobNotice && encryptionService.getPrivateKey() &&
283283
<Button
284284
type="dashed"
285285
size="large"

src/services/EncryptionService.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ class EncryptionService {
105105
}, 30 * 60 * 1000);
106106
};
107107

108+
/**
109+
* Checks if a possible private key is in the local storage
110+
*
111+
* @author dvonderbey@communicode.de
112+
* @return {Boolean} - The availability of a possible private key in the local storage
113+
* @since 0.17.0
114+
*/
115+
getPrivateKey = () => {
116+
return localStorage.getItem("privateKey");
117+
}
118+
108119
/**
109120
* Checks if the set passphrase is valid.
110121
*
@@ -114,7 +125,7 @@ class EncryptionService {
114125
*/
115126
checkPassphrase = () => {
116127
return new Promise((resolve, reject) => {
117-
let encryptedPem = localStorage.getItem("privateKey");
128+
let encryptedPem = this.getPrivateKey();
118129
this.encryptedPrivateKeyPem = encryptedPem;
119130
if (encryptedPem) {
120131
try {
@@ -154,7 +165,7 @@ class EncryptionService {
154165
loadPrivateKey = (privateKey) => {
155166
return new Promise((resolve, reject) => {
156167
privateKey && localStorage.setItem("privateKey", privateKey);
157-
let encryptedPem = localStorage.getItem("privateKey");
168+
let encryptedPem = this.getPrivateKey();
158169
if (encryptedPem) {
159170
this.checkForPassphrase()
160171
.then(() => {
@@ -214,7 +225,7 @@ class EncryptionService {
214225
* @since 0.15.0
215226
*/
216227
checkKeyStatus = () => {
217-
if(_.isEmpty(localStorage.getItem("privateKey"))) {
228+
if(_.isEmpty(this.getPrivateKey())) {
218229
if(_.isEmpty(authStore.publicKey)) {
219230
notificationService.info("No key set", "You haven't setup a key for your account yet. Please use the wizard to install one.", 10);
220231
this.wizardEnabled = true;
@@ -276,8 +287,8 @@ class EncryptionService {
276287
* @author dvonderbey@communicode.de
277288
*/
278289
downloadPrivateKey = () => {
279-
if (localStorage.getItem("privateKey")) {
280-
fileDownload(localStorage.getItem("privateKey"), "privateKey-" + authStore.login + ".pem");
290+
if (this.getPrivateKey()) {
291+
fileDownload(this.getPrivateKey(), "privateKey-" + authStore.login + ".pem");
281292
}
282293
};
283294

0 commit comments

Comments
 (0)