From f4996973aa2282abb15308533bc65257a6073ab2 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Tue, 16 Jul 2019 16:45:16 +0300 Subject: [PATCH] register ajax cors added --- .../src/Http/Middleware/Cors.php | 32 +++++++++++++ .../src/ProfileModuleServiceProvider.php | 19 ++++++-- composer.json | 45 ++++++++++++------- config/app.php | 1 + 4 files changed, 78 insertions(+), 19 deletions(-) create mode 100644 addons/default/visiosoft/profile-module/src/Http/Middleware/Cors.php diff --git a/addons/default/visiosoft/profile-module/src/Http/Middleware/Cors.php b/addons/default/visiosoft/profile-module/src/Http/Middleware/Cors.php new file mode 100644 index 000000000..174c974e0 --- /dev/null +++ b/addons/default/visiosoft/profile-module/src/Http/Middleware/Cors.php @@ -0,0 +1,32 @@ + false, + 'allowedOrigins' => ['*'],// ex: ['abc.com', 'api.abc.com'] + 'allowedHeaders' => ['*'], + 'allowedMethods' => ['*'],// ex: ['GET', 'POST', 'PUT', 'DELETE'] + 'exposedHeaders' => [], + 'maxAge' => 0, + + ]; + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php index 0c132d29d..652e477d3 100644 --- a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php +++ b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php @@ -5,6 +5,7 @@ use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface; use Visiosoft\ProfileModule\Adress\AdressRepository; use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel; use Visiosoft\ProfileModule\Adress\AdressModel; +use Visiosoft\ProfileModule\Http\Middleware\Cors; use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface; use Visiosoft\ProfileModule\Profile\ProfileRepository; use Anomaly\Streams\Platform\Model\Profile\ProfileProfileEntryModel; @@ -42,7 +43,8 @@ class ProfileModuleServiceProvider extends AddonServiceProvider * * @type array|null */ - protected $api = []; + protected $api = [ + ]; /** * The addon routes. @@ -95,7 +97,16 @@ class ProfileModuleServiceProvider extends AddonServiceProvider 'profile/notification' => [ 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@notification', ], - 'register/ajax' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@registerAjax', + + + 'register/ajax' =>[ + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@registerAjax', + 'middleware' => [ + \Barryvdh\Cors\HandleCors::class, + ], + ], + + ]; @@ -124,7 +135,9 @@ class ProfileModuleServiceProvider extends AddonServiceProvider * * @type array|null */ - protected $routeMiddleware = []; + protected $routeMiddleware = [ + 'cors' => Cors::class, + ]; /** * The addon event listeners. diff --git a/composer.json b/composer.json index c821e686e..58720e510 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require": { "wikimedia/composer-merge-plugin": "~1.4.0", "anomaly/streams-composer-plugin": "~1.1.0", - "anomaly/streams-platform": "~1.5.0", + "anomaly/streams-platform": "~1.6.0", "anomaly/default_authenticator-extension": "~2.1.0", "anomaly/throttle_security_check-extension": "~2.1.0", "anomaly/local_storage_adapter-extension": "~2.1.0", @@ -26,12 +26,13 @@ "anomaly/xml_feed_widget-extension": "~2.1.0", "anomaly/page_link_type-extension": "~2.1.0", "anomaly/url_link_type-extension": "~2.1.0", + "anomaly/encrypted-field_type": "~2.1.0", "anomaly/relationship-field_type": "~2.2.0", "anomaly/polymorphic-field_type": "~2.1.0", "anomaly/checkboxes-field_type": "~2.4.0", "anomaly/datetime-field_type": "~3.0.0", "anomaly/language-field_type": "~2.2.0", - "anomaly/multiple-field_type": "~2.2.0", + "anomaly/multiple-field_type": "~2.3.0", "anomaly/textarea-field_type": "~2.1.0", "anomaly/wysiwyg-field_type": "~3.1.0", "anomaly/boolean-field_type": "~2.3.0", @@ -41,33 +42,40 @@ "anomaly/select-field_type": "~2.3.0", "anomaly/addon-field_type": "~2.2.0", "anomaly/email-field_type": "~2.1.0", - "anomaly/files-field_type": "~2.2.0", - "anomaly/tags-field_type": "~2.3.0", + "anomaly/state-field_type": "~2.3.0", + "anomaly/files-field_type": "~2.3.0", + "anomaly/tags-field_type": "~2.4.0", "anomaly/slug-field_type": "~2.1.0", "anomaly/text-field_type": "~2.2.0", "anomaly/file-field_type": "~2.2.0", "anomaly/url-field_type": "~2.2.0", "anomaly/configuration-module": "~2.1.0", - "anomaly/preferences-module": "~2.1.0", + "anomaly/preferences-module": "~2.2.0", "anomaly/navigation-module": "~2.4.0", "anomaly/dashboard-module": "~2.2.0", - "anomaly/redirects-module": "~2.2.0", - "anomaly/variables-module": "~2.3.0", - "anomaly/settings-module": "~2.3.0", - "anomaly/addons-module": "~2.2.0", - "anomaly/blocks-module": "~1.2.0", - "anomaly/users-module": "~2.4.0", - "anomaly/pages-module": "~2.5.0", - "anomaly/posts-module": "~2.5.0", - "anomaly/files-module": "~2.5.0", + "anomaly/redirects-module": "~2.3.0", + "anomaly/variables-module": "~2.4.0", + "anomaly/settings-module": "~2.4.0", + "anomaly/addons-module": "~2.3.0", + "anomaly/blocks-module": "~1.3.0", + "anomaly/system-module": "~1.0.0", + "anomaly/users-module": "~2.5.0", + "anomaly/pages-module": "~2.6.0", + "anomaly/posts-module": "~2.6.0", + "anomaly/files-module": "~2.6.0", "anomaly/contact-plugin": "~1.2.0", "anomaly/helper-plugin": "~2.1.0", "anomaly/robots-extension": "~2.1.0", - "anomaly/sitemap-extension": "~2.1.0", + "anomaly/sitemap-extension": "~2.2.0", "anomaly/html_block-extension": "~1.0.0", "anomaly/wysiwyg_block-extension": "~1.0.0", + "guzzlehttp/guzzle": "~6.3.3", "ammadeuss/laravel-html-dom-parser": "^1.1", - "guzzlehttp/guzzle": "~6.3.3" + "visiosoft/subscriptions-module": "^1.0", + "visiosoft/orders-module": "^1.0", + "visiosoft/notifications-module": "^1.0", + "visiosoft/site_method_jenkins-module": "^1.0", + "barryvdh/laravel-cors": "^0.11.3" }, "require-dev": { "filp/whoops": "~2.0", @@ -114,6 +122,11 @@ ], "recurse": true, "replace": false + }, + "laravel": { + "dont-discover": [ + "*" + ] } }, "config": { diff --git a/config/app.php b/config/app.php index d30a0f6a8..31e3cef15 100644 --- a/config/app.php +++ b/config/app.php @@ -178,6 +178,7 @@ return [ Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, + Barryvdh\Cors\ServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class,