From 354ffb0a50bb78e252471a8f9ac0c12ba19ef260 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Wed, 6 Oct 2021 09:53:28 +0300 Subject: [PATCH 1/2] fix auth --- .../visiosoft/advs-module/src/AdvsModuleServiceProvider.php | 5 +++++ .../advs-module/src/Http/Controller/AdvsController.php | 4 ---- .../src/Http/Controller/MyProfileController.php | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php index 2c0fcdb63..e0aedcb40 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php @@ -114,10 +114,12 @@ class AdvsModuleServiceProvider extends AddonServiceProvider ], 'advs/create_adv' => [ 'as' => "advs::create_adv", + 'middleware' => 'auth', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@cats', ], 'advs/create_adv/post_cat' => [ 'as' => 'post_adv', + 'middleware' => 'auth', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@create', ], 'advs/save_adv' => [ @@ -135,6 +137,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider ], 'advs/delete/{id}' => [ 'as' => 'advs::delete', + 'middleware' => 'auth', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@deleteAd', ], 'adv/addCart/{id}' => [ @@ -205,6 +208,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider //Configurations Admin Controller 'admin/advs/option_configuration/create' => [ + 'middleware' => 'auth', 'as' => 'visiosoft.module.advs::configrations.create', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\OptionConfigurationController@create', ], @@ -215,6 +219,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider //Configuration Controller 'advs/option_configuration/create' => [ + 'middleware' => 'auth', 'as' => 'visiosoft.module.advs::user.configrations.create', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\OptionConfigurationController@create', ], diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php index fd1b1e83c..1ed74021a 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php @@ -711,7 +711,6 @@ class AdvsController extends PublicController public function deleteAd(AdvRepositoryInterface $advs, $id) { $ad = $this->adv_model->find($id); - $this->middleware('auth'); if ($ad->created_by_id != Auth::id()) { $this->messages->error(trans('visiosoft.module.advs::message.delete_author_error')); @@ -743,8 +742,6 @@ class AdvsController extends PublicController public function create(AdvFormBuilder $formBuilder, CategoryRepositoryInterface $repository) { - $this->middleware('auth'); - $isActive = new AdvModel(); $cats = $this->request->toArray(); unset($cats['_token']); @@ -1059,7 +1056,6 @@ class AdvsController extends PublicController public function cats() { - $this->middleware('auth'); $main_cats = $this->category_repository->getMainCategories(); return $this->view->make('visiosoft.module.advs::new-ad/post-cat', compact('main_cats')); diff --git a/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php b/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php index 8042a6013..08fc52ddd 100644 --- a/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php +++ b/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php @@ -34,7 +34,11 @@ class MyProfileController extends PublicController ) { parent::__construct(); - $this->middleware('auth'); + + if (!Auth::user()) { + redirect('/login?redirect=' . url()->current())->send(); + } + $this->adressRepository = $adressRepository; $this->userRepository = $userRepository; } From 1502781aae32cf28fc7686ead58e0fe527680141 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Wed, 6 Oct 2021 10:02:59 +0300 Subject: [PATCH 2/2] fix auth --- .../Http/Controller/MyProfileController.php | 4 -- .../src/ProfileModuleServiceProvider.php | 46 +++++++++++++++---- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php b/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php index 08fc52ddd..1fa2d90d1 100644 --- a/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php +++ b/addons/default/visiosoft/profile-module/src/Http/Controller/MyProfileController.php @@ -35,10 +35,6 @@ class MyProfileController extends PublicController { parent::__construct(); - if (!Auth::user()) { - redirect('/login?redirect=' . url()->current())->send(); - } - $this->adressRepository = $adressRepository; $this->userRepository = $userRepository; } diff --git a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php index 3cb843f31..ede582c74 100644 --- a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php +++ b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php @@ -46,44 +46,72 @@ class ProfileModuleServiceProvider extends AddonServiceProvider // MyProfileController 'profile/ads' => [ 'as' => 'profile::ads', + 'middleware' => 'auth', 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@myAds' ], 'profile/adress/ajaxCreate' => [ 'as' => 'visiosoft.module.profile::adress_ajax_create', + 'middleware' => 'auth', 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@adressAjaxCreate' ], 'profile/adress/ajaxUpdate/{id}' => [ 'as' => 'visiosoft.module.profile::adress_ajax_update', + 'middleware' => 'auth', 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@adressAjaxUpdate' ], 'profile/adress/ajaxDetail' => [ 'as' => 'visiosoft.module.profile::adress_ajax_detail', + 'middleware' => 'auth', 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@adressAjaxDetail' ], 'profile' => [ 'as' => 'profile::profile', + 'middleware' => 'auth', 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@home' ], 'profile/detail' => [ 'as' => 'profile::detail', - 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@detail' + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@detail' ], 'profile/password' => [ 'as' => 'profile::password', - 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@password' + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@password' ], - 'profile/class/status/{id},{type}' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@statusAds', - 'profile/class/extendTime/{id},{type}' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@extendAds', - 'profile/message/show/{id}' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@showMessage', + 'profile/class/status/{id},{type}' => [ + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@statusAds', + ], + 'profile/class/extendTime/{id},{type}' => [ + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@extendAds', + ], + 'profile/message/show/{id}' => [ + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@showMessage', + ], 'profile/close-account' => [ 'middleware' => 'auth', 'as' => 'visiosoft.module.profile::profile_close_account', 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@disableAccount' ], - 'profile/notification' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@notification', - 'ajax/update-user-info' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@updateAjaxProfile', - 'api/changeEducation' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@changeEducation', - 'api/getEducation' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@getEducation', + 'profile/notification' => [ + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@notification', + 'middleware' => 'auth', + ], + 'ajax/update-user-info' => [ + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@updateAjaxProfile', + ], + 'api/changeEducation' => [ + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@changeEducation', + ], + 'api/getEducation' => [ + 'middleware' => 'auth', + 'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@getEducation', + ], // UserAuthenticator 'login-in' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@attempt',