@@ -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