@@ -30,33 +30,52 @@ function acquireLsk(successCallback, errorCallback) {
30
30
}
31
31
32
32
// Otherwise, open the OutSystems key store
33
- var ss = new SecureStorage (
34
- function ( ) {
35
- // and when initialized attempt to get the stored key
36
- ss . get (
37
- function ( value ) {
38
- lskCache = value ;
39
- console . log ( "Got Local Storage key" ) ;
40
- successCallback ( lskCache ) ;
41
- } ,
42
- function ( error ) {
43
- // If there's no key yet, generate a new one and store it
44
- var newKey = generateKey ( ) ;
45
- lskCache = undefined ;
46
- console . log ( "Setting new Local Storage key" ) ;
47
- ss . set (
48
- function ( key ) {
49
- lskCache = newKey ;
50
- successCallback ( lskCache ) ;
51
- } ,
52
- errorCallback ,
53
- LOCAL_STORAGE_KEY ,
54
- newKey ) ;
55
- } ,
56
- LOCAL_STORAGE_KEY ) ;
57
- } ,
58
- errorCallback ,
59
- OUTSYSTEMS_KEYSTORE ) ;
33
+ var initFn = function ( ) {
34
+ var ss = new SecureStorage (
35
+ function ( ) {
36
+ // and when initialized attempt to get the stored key
37
+ ss . get (
38
+ function ( value ) {
39
+ lskCache = value ;
40
+ console . log ( "Got Local Storage key" ) ;
41
+ successCallback ( lskCache ) ;
42
+ } ,
43
+ function ( error ) {
44
+ // If there's no key yet, generate a new one and store it
45
+ var newKey = generateKey ( ) ;
46
+ lskCache = undefined ;
47
+ console . log ( "Setting new Local Storage key" ) ;
48
+ ss . set (
49
+ function ( key ) {
50
+ lskCache = newKey ;
51
+ successCallback ( lskCache ) ;
52
+ } ,
53
+ errorCallback ,
54
+ LOCAL_STORAGE_KEY ,
55
+ newKey ) ;
56
+ } ,
57
+ LOCAL_STORAGE_KEY ) ;
58
+ } ,
59
+ function ( error ) {
60
+ if ( error . message === "Device is not secure" ) {
61
+ if ( window . confirm ( "In order to use this app, your device must have a secure lock screen. Press OK to setup your device." ) ) {
62
+ ss . secureDevice (
63
+ initFn ,
64
+ function ( ) {
65
+ navigator . app . exitApp ( ) ;
66
+ }
67
+ ) ;
68
+ } else {
69
+ navigator . app . exitApp ( ) ;
70
+ }
71
+ } else {
72
+ errorCallback ( error ) ;
73
+ }
74
+ } ,
75
+ OUTSYSTEMS_KEYSTORE ) ;
76
+ } ;
77
+
78
+ initFn ( ) ;
60
79
}
61
80
62
81
/**
0 commit comments