diff options
author | nachoparker <nacho@ownyourbits.com> | 2018-04-11 02:16:51 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2018-04-11 02:24:56 +0300 |
commit | 8b90ec2d1aaba8d8f120a40b8e9f26b1ee22f76b (patch) | |
tree | 450cef42118baa3fd18a97234d6e171549ff1e63 /ncp-web | |
parent | f34a3ce9d4b5d6ac15975001f9ad532c6aec93ef (diff) |
ncp-web: auto-retry upon activation whenever NCP has not yet fully initialized
Diffstat (limited to 'ncp-web')
-rw-r--r-- | ncp-web/activate/JS.js | 47 | ||||
-rw-r--r-- | ncp-web/activate/index.php | 2 |
2 files changed, 29 insertions, 20 deletions
diff --git a/ncp-web/activate/JS.js b/ncp-web/activate/JS.js index dd00dcec..b9463648 100644 --- a/ncp-web/activate/JS.js +++ b/ncp-web/activate/JS.js @@ -21,7 +21,7 @@ function launch_nc_passwd() { // request $.request('post', '../ncp-launcher.php', { action: 'launch', - ref : 'nc-passwd', + ref : 'nc-passwd', config: '{ "PASSWORD":"' + $('#ncp-pwd').get('.value') + '",' + '"CONFIRM" :"' + $('#ncp-pwd').get('.value') + '"}', csrf_token: $( '#csrf-token' ).get( '.value' ) }).then( @@ -44,6 +44,31 @@ function launch_nc_passwd() } ).error( errorMsg ); } +function nc_admin_ok_cb( result ) +{ + var ret = $.parseJSON( result ); + if ( ret.token ) + $('#csrf-token').set( { value: ret.token } ); + if ( ret.ret == '0' ) { + launch_nc_passwd(); + } else { + $('#error-box').fill( "NextCloudPlus not yet initialized, trying again in a few seconds ..." ); + setTimeout( launch_activation, 10000 ); + } +} + +function launch_activation() +{ + // request + $.request('post', '../ncp-launcher.php', { action: 'launch', + ref : 'nc-admin', + config: '{ "PASSWORD":"' + $('#nc-pwd').get('.value') + '",' + + '"CONFIRM" :"' + $('#nc-pwd').get('.value') + '",' + + '"USER" : "ncp" }', + csrf_token: $( '#csrf-token' ).get( '.value' ) } + ).then( nc_admin_ok_cb ).error( errorMsg ); +} + $(function() { // print info page @@ -77,25 +102,7 @@ $(function() $( '#activate-ncp' ).hide(); $( '#print-pwd' ).hide(); $('#loading-gif').set( { $display: 'inline' } ); - - // request - $.request('post', '../ncp-launcher.php', { action: 'launch', - ref : 'nc-admin', - config: '{ "PASSWORD":"' + $('#nc-pwd').get('.value') + '",' - + '"CONFIRM" :"' + $('#nc-pwd').get('.value') + '",' - + '"USER" : "ncp" }', - csrf_token: $( '#csrf-token' ).get( '.value' ) }).then( - function success( result ) - { - var ret = $.parseJSON( result ); - if ( ret.ret == '0' ) { - if ( ret.token ) - $('#csrf-token').set( { value: ret.token } ); - launch_nc_passwd(); - } else { - $('#error-box').fill( "nc-admin error" ); - } - } ).error( errorMsg ); + launch_activation(); } ); } ); diff --git a/ncp-web/activate/index.php b/ncp-web/activate/index.php index 0b08f61e..f1fb697b 100644 --- a/ncp-web/activate/index.php +++ b/ncp-web/activate/index.php @@ -7,6 +7,8 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="referrer" content="never"> <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> + <meta http-equiv="cache-control" content="no-cache"> + <meta http-equiv="pragma" content="no-cache"> <link rel="icon" type="image/png" href="img/favicon.png"/> <link rel="stylesheet" href="CSS.css"> <?php session_start(); ?> |