From acb63c93868f8f119938c023b1a83faf95b28f00 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 20 Feb 2020 10:24:46 +0300 Subject: [PATCH] chore(admin-plugin): set default API's tokens on user installation process --- site/plugins/admin/app/Controllers/UsersController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/site/plugins/admin/app/Controllers/UsersController.php b/site/plugins/admin/app/Controllers/UsersController.php index 0ea9b0f3..4499444e 100644 --- a/site/plugins/admin/app/Controllers/UsersController.php +++ b/site/plugins/admin/app/Controllers/UsersController.php @@ -187,6 +187,15 @@ class UsersController extends Controller ], 'yaml') ); + // Set Default API's tokens + $custom_flextype_settings_file_path = PATH['config']['site'] . '/settings.yaml'; + $custom_flextype_settings_file_data = $this->parser->decode(Filesystem::read($custom_flextype_settings_file_path), 'yaml'); + + $custom_flextype_settings_file_data['api']['images']['default_token'] = $api_delivery_images_token; + $custom_flextype_settings_file_data['api']['entries']['default_token'] = $api_delivery_entries_token; + + Filesystem::write($custom_flextype_settings_file_path, $this->parser->encode($custom_flextype_settings_file_data, 'yaml')); + return $response->withRedirect($this->router->pathFor('admin.users.login')); }