From f8c7233427c4f4dc9afa23917000165bd94ebb27 Mon Sep 17 00:00:00 2001 From: Witel Group Date: Tue, 9 Jul 2024 09:58:14 +0000 Subject: [PATCH] modified session attributes for Dev env| added login dev route for local development --- .env.example | 4 +- config/cors.php | 9 +-- config/global_variables.php | 5 ++ config/session.php | 9 ++- routes/api.php | 10 --- routes/web.php | 127 +++++++++++++++++++----------------- 6 files changed, 87 insertions(+), 77 deletions(-) create mode 100644 config/global_variables.php diff --git a/.env.example b/.env.example index 847530ff..8522c411 100644 --- a/.env.example +++ b/.env.example @@ -55,4 +55,6 @@ RMS_CTO_PHONE_NUMBER="09380220400" TELESCOPE_RESPONSE_SIZE_LIMIT=128 -DEBUGBAR_ENABLED=false \ No newline at end of file +DEBUGBAR_ENABLED=false + +IS_DEVELOPMENT_ENV=true diff --git a/config/cors.php b/config/cors.php index e3404413..71003762 100644 --- a/config/cors.php +++ b/config/cors.php @@ -21,11 +21,12 @@ return [ * You can enable CORS for 1 or multiple paths. * Example: ['api/*'] */ - 'paths' => ['api/public/*', 'public/*'], + // 'paths' => ['api/public/*', 'public/*'], + 'paths' => ['*'], /* - * Matches the request method. `[*]` allows all methods. - */ + * Matches the request method. `[*]` allows all methods. + */ 'allowed_methods' => ['*'], /* @@ -56,5 +57,5 @@ return [ /* * Sets the Access-Control-Allow-Credentials header. */ - 'supports_credentials' => false, + 'supports_credentials' => true, ]; diff --git a/config/global_variables.php b/config/global_variables.php new file mode 100644 index 00000000..cc7b9df3 --- /dev/null +++ b/config/global_variables.php @@ -0,0 +1,5 @@ + env('IS_DEVELOPMENT_ENV', false), +]; diff --git a/config/session.php b/config/session.php index 768f5520..226cac5e 100644 --- a/config/session.php +++ b/config/session.php @@ -2,6 +2,9 @@ use Illuminate\Support\Str; +$sameSite = env('IS_DEVELOPMENT_ENV') ? 'none' : null; +$secure = env('IS_DEVELOPMENT_ENV') ? true : false; + return [ /* @@ -126,7 +129,7 @@ return [ 'cookie' => env( 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_').'_session' + Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' ), /* @@ -166,7 +169,7 @@ return [ | */ - 'secure' => env('SESSION_SECURE_COOKIE', false), + 'secure' => $secure, /* |-------------------------------------------------------------------------- @@ -194,6 +197,6 @@ return [ | */ - 'same_site' => null, + 'same_site' => $sameSite, ]; diff --git a/routes/api.php b/routes/api.php index 474538ce..652c0dba 100644 --- a/routes/api.php +++ b/routes/api.php @@ -476,15 +476,5 @@ Route::get('get-constituencies/{province_id}', 'LawmakersController@getConstitue // Route::get('add-perm', 'DevelopController@addPermissions'); - - - - - - - - - - // ////// for 141 toll house rahdar khane ha Route::middleware('cors:api')->get('/get_road_toll', 'RahdariPointController@get_road_toll_for_141'); diff --git a/routes/web.php b/routes/web.php index 30eef8c3..0fac35aa 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,6 +14,7 @@ use App\Http\Controllers\Api\ForgotPasswordController; use App\Models\TarhList; use App\Models\Contracts; + // use SoapFault; // use SoapClient; @@ -184,23 +185,23 @@ Route::get('rmtologin', function () { // /* cmms's view */ - Route::get('cmms-audit', function () { - return view('cmms.audit_index'); - }); // view - Route::get('cmms-audit/add', function () { - return view('cmms.audit_create'); - }); // view +Route::get('cmms-audit', function () { + return view('cmms.audit_index'); +}); // view +Route::get('cmms-audit/add', function () { + return view('cmms.audit_create'); +}); // view - Route::get('cmms-audit/{id}/edit', function (Illuminate\Http\Request $request) { - $id = $request->id; +Route::get('cmms-audit/{id}/edit', function (Illuminate\Http\Request $request) { + $id = $request->id; - return view('cmms.audit_update', compact('id')); - }); // view + return view('cmms.audit_update', compact('id')); +}); // view - Route::get('cmms/all', 'Api\CMMSController@index'); // api +Route::get('cmms/all', 'Api\CMMSController@index'); // api // Route::post('cmms/create', 'Api\CMMSController@store'); // api // Route::get('cmms/provinces/all', 'Api\CMMSController@getProvinces'); // api - Route::post('cmms/{id}/edit', 'Api\CMMSController@update'); // api +Route::post('cmms/{id}/edit', 'Api\CMMSController@update'); // api // Route::resource('road-items', 'RoadItemsProjectController')->except([ @@ -211,7 +212,7 @@ Route::get('rmtologin', function () { // 'show', 'update', 'destroy' // ]); - Route::get('bi/subtitleCounts', 'Api\BiController@getSubtitleCounts'); +Route::get('bi/subtitleCounts', 'Api\BiController@getSubtitleCounts'); // Route::view('rmtobi', 'rmto-preview.BI'); // Route::get('project_list', 'RoadConstructionProjectController@index'); @@ -239,7 +240,7 @@ Route::get('users/summary_report/{user}', 'UserController@getUserSummaryReport') // Route::get('users/projects', 'UserController@getNewUserProjects'); // Route::get('users/get_user_permissions_types', 'UserController@getUserPermissionsTypes'); Route::post('users/change_confirmed_status', 'UserController@changeConfirmedStatus'); - Route::get('users/change_user_enabeld/{user}', 'UserController@changeUserEnabeld'); +Route::get('users/change_user_enabeld/{user}', 'UserController@changeUserEnabeld'); Route::post('users/give_permissions', 'UserController@givePermissionsTo'); Route::post('users/delete', 'UserController@destroy'); // Route::post('users/{id}', 'UserController@update'); @@ -260,7 +261,7 @@ Route::post('users/delete', 'UserController@destroy'); // Route::get('public/projects/ristat', 'UserController@getRoadItemsProjectsStat'); // Route::get('public/projects/getrirpadmin/{id}', 'UserController@getAdminProvinceProjectsItem'); - Route::get('/karbarlist_old', 'View\UserController@showKarbarlist')->middleware(['auth', 'confirmUser'])->name('show.usermanagement'); +Route::get('/karbarlist_old', 'View\UserController@showKarbarlist')->middleware(['auth', 'confirmUser'])->name('show.usermanagement'); // // Route::get('/profile-getinfo', 'UserController@profile'); @@ -272,7 +273,7 @@ Route::middleware('auth')->resource('users', 'UserController'); Route::get('webapi/user/get-permission', 'UserController@getUserPermissions')->middleware(['auth']); Route::post('add-simple-users', 'UserController@simpleAddUser'); // Route::post('edit-role/{id}', 'UserController@editRole'); - Route::post('create-role', 'UserController@createRole'); +Route::post('create-role', 'UserController@createRole'); // Route::post('delete-role/{id}', 'UserController@deleteRole'); Route::get('user/permissions', 'UserController@getAllPermissions'); @@ -357,27 +358,27 @@ Route::get('/user-activity-report/print/user/{user}', 'UserController@printGroup // // dayli accident begin - // Route::get('/daily_accident', 'View\DailyAccidentController@index'); - Route::get('/daily_accident/show', 'DailyAccidentController@show'); - Route::post('/daily_accident/store', 'DailyAccidentController@store'); - Route::post('/daily_accident/update/{accident}', 'DailyAccidentController@update'); - Route::post('/daily_accident/delete/{accident}', 'DailyAccidentController@delete'); +// Route::get('/daily_accident', 'View\DailyAccidentController@index'); +Route::get('/daily_accident/show', 'DailyAccidentController@show'); +Route::post('/daily_accident/store', 'DailyAccidentController@store'); +Route::post('/daily_accident/update/{accident}', 'DailyAccidentController@update'); +Route::post('/daily_accident/delete/{accident}', 'DailyAccidentController@delete'); // Route::get('/daily_accident/get_pending_accidents_count', 'DailyAccidentController@getPendingAccidentsCount'); - Route::get('/daily_accident/accident_reasons', 'DailyAccidentController@getAccidentReasons'); - Route::get('/daily_accident/accident_increase_damage_reasons', 'DailyAccidentController@getAccidentIncreaseDamageReasons'); - Route::get('/daily_accident/get_participants', 'DailyAccidentController@getParticipants'); - Route::get('/daily_accident/accident_types', 'DailyAccidentController@getAccidentTypes'); - Route::get('/daily_accident/get_accident_collision_type', 'DailyAccidentController@getAccidentCollisionType'); +Route::get('/daily_accident/accident_reasons', 'DailyAccidentController@getAccidentReasons'); +Route::get('/daily_accident/accident_increase_damage_reasons', 'DailyAccidentController@getAccidentIncreaseDamageReasons'); +Route::get('/daily_accident/get_participants', 'DailyAccidentController@getParticipants'); +Route::get('/daily_accident/accident_types', 'DailyAccidentController@getAccidentTypes'); +Route::get('/daily_accident/get_accident_collision_type', 'DailyAccidentController@getAccidentCollisionType'); - Route::get('/daily_accident/{accident}', 'DailyAccidentController@details'); - Route::post('/daily_accident/set_state/{accident}', 'DailyAccidentController@setState'); +Route::get('/daily_accident/{accident}', 'DailyAccidentController@details'); +Route::post('/daily_accident/set_state/{accident}', 'DailyAccidentController@setState'); - Route::get('/daily_accident_poster', 'DailyAccidentController@poster'); +Route::get('/daily_accident_poster', 'DailyAccidentController@poster'); // Route::get('/daily_accident_poster_information', 'DailyAccidentController@getPosterInformation'); // Route::get('/daily_accident_map', 'View\DailyAccidentController@map'); - Route::get('/daily_accident_map/accidents', 'DailyAccidentController@getAccidents'); +Route::get('/daily_accident_map/accidents', 'DailyAccidentController@getAccidents'); // // dayli accident end @@ -939,11 +940,11 @@ Route::middleware('cors:api')->post('csi/update-dev/{id}', 'Api\ContractSubItems // // proposals routes // Route::middleware('web', 'auth', 'confirmUser')->group(function () { // Route::get('/proposal', 'View\ProposalController@view'); - Route::get('webapi/proposal/get-data', 'ProposalController@index'); +Route::get('webapi/proposal/get-data', 'ProposalController@index'); // Route::get('webapi/proposal/show/{id}', 'ProposalController@show'); - Route::post('webapi/proposal/store', 'ProposalController@store'); - Route::post('webapi/proposal/update/{proposal}', 'ProposalController@update'); - Route::post('webapi/proposal/delete/{proposal}', 'ProposalController@delete'); +Route::post('webapi/proposal/store', 'ProposalController@store'); +Route::post('webapi/proposal/update/{proposal}', 'ProposalController@update'); +Route::post('webapi/proposal/delete/{proposal}', 'ProposalController@delete'); // Route::get('webapi/proposal/histories/{proposal}', 'ProposalController@show'); // }); @@ -951,10 +952,10 @@ Route::middleware('cors:api')->post('csi/update-dev/{id}', 'Api\ContractSubItems // // Lawmakers routes // Route::middleware('web', 'auth', 'confirmUser')->group(function () { // Route::get('lawmakers', 'View\LawmakersController@view'); - Route::post('lawmakers/update/{lawmakers}', 'LawmakersController@update'); - Route::post('lawmakers/store', 'LawmakersController@store'); - Route::post('lawmakers/delete/{lawmaker}', 'LawmakersController@delete'); - Route::get('lawmakers/all', 'LawmakersController@index'); +Route::post('lawmakers/update/{lawmakers}', 'LawmakersController@update'); +Route::post('lawmakers/store', 'LawmakersController@store'); +Route::post('lawmakers/delete/{lawmaker}', 'LawmakersController@delete'); +Route::get('lawmakers/all', 'LawmakersController@index'); // }); Route::middleware('web', 'auth', 'confirmUser')->group(function () { @@ -1480,28 +1481,36 @@ Route::get('/', function () { // return redirect(route('v2.dashboard')); // }); -// /// +// \Illuminate\Support\Facades\Route::get('witel', function () { +// $user = User::create([ +// 'username' => 'witel', +// 'password' => Hash::make('Witel@fani0') +// ]); -\Illuminate\Support\Facades\Route::get('witel', function () { - $user = User::create([ - 'username' => 'witel', - 'password' => Hash::make('Witel@fani0') - ]); +// $sqlFile1 = file_get_contents(storage_path('/sql-files/permissions.sql')); +// $sqlFile2 = file_get_contents(storage_path('/sql-files/provinces.sql')); +// $sqlFile3 = dev(storage_path('/sql-files/cities.sql')); +// $sqlFile4 = file_get_contents(storage_path('/sql-files/edarate_shahri.sql')); +// $sqlFile5 = file_get_contents(storage_path('/sql-files/log_lists.sql')); +// $sqlFile6 = file_get_contents(storage_path('/sql-files/info_items.sql')); +// DB::unprepared($sqlFile1); +// DB::unprepared($sqlFile2); +// DB::unprepared($sqlFile3); +// DB::unprepared($sqlFile4); +// DB::unprepared($sqlFile5); +// DB::unprepared($sqlFile6); - $sqlFile1 = file_get_contents(storage_path('/sql-files/permissions.sql')); - $sqlFile2 = file_get_contents(storage_path('/sql-files/provinces.sql')); - $sqlFile3 = file_get_contents(storage_path('/sql-files/cities.sql')); - $sqlFile4 = file_get_contents(storage_path('/sql-files/edarate_shahri.sql')); - $sqlFile5 = file_get_contents(storage_path('/sql-files/log_lists.sql')); - $sqlFile6 = file_get_contents(storage_path('/sql-files/info_items.sql')); - DB::unprepared($sqlFile1); - DB::unprepared($sqlFile2); - DB::unprepared($sqlFile3); - DB::unprepared($sqlFile4); - DB::unprepared($sqlFile5); - DB::unprepared($sqlFile6); +// $user->givePermissionTo(Permission::all()); - $user->givePermissionTo(Permission::all()); +// return 'ok'; +// }); +if (config('global_variables.IS_DEVELOPMENT_ENV') === true) { + Route::get('login_dev', function (Request $request) { + + $request->validate([ + 'username' => 'required', + ]); - return 'ok'; -}); \ No newline at end of file + Auth::loginUsingId(User::where('username', $request->username)->first()->id); + }); +} \ No newline at end of file