From 892197997ac1cdf52bd4a0e462cbfb73d5883d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Thu, 25 Jun 2020 14:38:33 +0200 Subject: [PATCH 1/3] rework autentication so reautentication works --- src/components/AppleMap.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/components/AppleMap.js b/src/components/AppleMap.js index 5a58a2e..54842c3 100644 --- a/src/components/AppleMap.js +++ b/src/components/AppleMap.js @@ -54,21 +54,25 @@ class AppleMap { } static authenticateMap() { - apiFetch( { path: 'MapsBlockApple/v1/GetJWT/' } ) - .then( ( token ) => { - mapkit.init( { - authorizationCallback( done ) { - done( token ); - }, + function getJWTToken( resolveCallback ) { + console.info( 'authenticate' ); + apiFetch( { path: 'MapsBlockApple/v1/GetJWT/' } ) + .then( resolveCallback ) + .catch( ( error ) => { + dispatch( 'core/notices' ).createErrorNotice( + error.message, + { + isDismissible: true, + type: 'snackbar', + } + ); + mapkit.dispatchEvent( new Event( 'error' ) ); } ); - } ) - .catch( ( error ) => { - dispatch( 'core/notices' ).createErrorNotice( error.message, { - isDismissible: true, - type: 'snackbar', - } ); - mapkit.dispatchEvent( new Event( 'error' ) ); - } ); + } + + mapkit.init( { + authorizationCallback: getJWTToken, + } ); } } From e03f0e67540b2bed92689ac55fd6dee6f42ec2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Thu, 25 Jun 2020 16:12:21 +0200 Subject: [PATCH 2/3] refresh --- src/edit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/edit.js b/src/edit.js index 3afa105..1a6f85e 100644 --- a/src/edit.js +++ b/src/edit.js @@ -52,8 +52,8 @@ export default function MapsBlockAppleEdit( props ) { break; case 'Refreshed': setIsLoading( false ); - setAuthenticated( false ); - mapkit.authenticated = false; + setAuthenticated( true ); + mapkit.authenticated = true; break; default: setIsLoading( false ); From 666fac8aae33c240d446a33cc000a2e17f29388f Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 25 Jun 2020 08:40:52 -0600 Subject: [PATCH 3/3] Remove errant console call --- src/components/AppleMap.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/AppleMap.js b/src/components/AppleMap.js index 54842c3..98d2737 100644 --- a/src/components/AppleMap.js +++ b/src/components/AppleMap.js @@ -55,7 +55,6 @@ class AppleMap { static authenticateMap() { function getJWTToken( resolveCallback ) { - console.info( 'authenticate' ); apiFetch( { path: 'MapsBlockApple/v1/GetJWT/' } ) .then( resolveCallback ) .catch( ( error ) => {