create roles and permissions
This commit is contained in:
@@ -27,13 +27,6 @@ DB_DATABASE=laravel
|
|||||||
DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=
|
||||||
|
|
||||||
ASTERISK_DB_CONNECTION=asterisk
|
|
||||||
ASTERISK_DB_HOST=127.0.0.1
|
|
||||||
ASTERISK_DB_PORT=3306
|
|
||||||
ASTERISK_DB_DATABASE=laravel
|
|
||||||
ASTERISK_DB_USERNAME=root
|
|
||||||
ASTERISK_DB_PASSWORD=
|
|
||||||
|
|
||||||
SESSION_DRIVER=database
|
SESSION_DRIVER=database
|
||||||
SESSION_LIFETIME=120
|
SESSION_LIFETIME=120
|
||||||
SESSION_ENCRYPT=false
|
SESSION_ENCRYPT=false
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class RoleManagementController extends Controller
|
|||||||
Role::query(),
|
Role::query(),
|
||||||
$request,
|
$request,
|
||||||
allowedFilters: array('id', 'name', 'name_fa'),
|
allowedFilters: array('id', 'name', 'name_fa'),
|
||||||
allowedSortings: array('id', 'name', 'name_fa'),
|
allowedRelations: array('permissions:id,name_fa'),
|
||||||
allowedRelations: array('permissions:id,name_fa')
|
allowedSortings: array('id', 'name', 'name_fa')
|
||||||
);
|
);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
|
|||||||
@@ -21,8 +21,11 @@ class VerifyAuthenticationController extends Controller
|
|||||||
|
|
||||||
$user = User::query()->findOrFail($request->user_id);
|
$user = User::query()->findOrFail($request->user_id);
|
||||||
|
|
||||||
Auth::login($user);
|
$token = $user->createToken("{$user->username}", ['*'], now()->addWeek())->plainTextToken;
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse([
|
||||||
|
'message' => __('messages.successful'),
|
||||||
|
'token' => $token
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
|
|
||||||
class VerifySetadIp
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle an incoming request.
|
|
||||||
*
|
|
||||||
* @param Closure(Request): (Response) $next
|
|
||||||
*/
|
|
||||||
public function handle(Request $request, Closure $next): Response
|
|
||||||
{
|
|
||||||
if ($request->ip() == config('globalVariables.SETAD_IP')) {
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
abort(Response::HTTP_FORBIDDEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,6 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
$middleware->statefulApi()->alias([
|
$middleware->statefulApi()->alias([
|
||||||
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||||
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
||||||
'setadIp' => \App\Http\Middleware\VerifySetadIp::class,
|
|
||||||
]);
|
]);
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions) {
|
->withExceptions(function (Exceptions $exceptions) {
|
||||||
|
|||||||
@@ -4,5 +4,4 @@ return [
|
|||||||
'TRUSTED_IP' => explode(',', env("TRUSTED_IP", '127.0.0.1')),
|
'TRUSTED_IP' => explode(',', env("TRUSTED_IP", '127.0.0.1')),
|
||||||
'NOTIFICATION_SERVER_URL' => env('NOTIFICATION_SERVER_URL', '127.0.0.1'),
|
'NOTIFICATION_SERVER_URL' => env('NOTIFICATION_SERVER_URL', '127.0.0.1'),
|
||||||
'LOGIN_HASH_VALUE' => env('LOGIN_HASH_VALUE'),
|
'LOGIN_HASH_VALUE' => env('LOGIN_HASH_VALUE'),
|
||||||
'SETAD_IP' => env('SETAD_IP'),
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -45,7 +45,103 @@ class PermissionSeeder extends Seeder
|
|||||||
'guard_name' => 'api',
|
'guard_name' => 'api',
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now()
|
'updated_at' => now()
|
||||||
]
|
],
|
||||||
|
[
|
||||||
|
'id' => 5,
|
||||||
|
'name' => 'country_calls_report',
|
||||||
|
'name_fa' => 'تجمعی تمام مراکز',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 6,
|
||||||
|
'name' => 'country_voice_rating',
|
||||||
|
'name_fa' => 'تجمعی کیفی تمام مراکز',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 7,
|
||||||
|
'name' => 'country_message_rating',
|
||||||
|
'name_fa' => 'تجمعی پیام های مردمی',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 8,
|
||||||
|
'name' => 'country_keypress_report',
|
||||||
|
'name_fa' => 'گزارش تماس ها',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 9,
|
||||||
|
'name' => 'supervise_operator_dialogue',
|
||||||
|
'name_fa' => 'ارزیابی مکالمات اپراتور',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 10,
|
||||||
|
'name' => 'supervise_system_message',
|
||||||
|
'name_fa' => 'ارزیابی پیام های سیستمی',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 11,
|
||||||
|
'name' => 'supervise_people_message',
|
||||||
|
'name_fa' => 'ارزیابی پیام های مردمی',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 12,
|
||||||
|
'name' => 'province_reports',
|
||||||
|
'name_fa' => 'گزارشات استان',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 13,
|
||||||
|
'name' => 'province_operator_dialogue',
|
||||||
|
'name_fa' => 'مکالمات اپراتور',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 14,
|
||||||
|
'name' => 'province_system_message',
|
||||||
|
'name_fa' => 'پیام های سیستمی',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 15,
|
||||||
|
'name' => 'province_people_message',
|
||||||
|
'name_fa' => 'پیام های مردمی',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 16,
|
||||||
|
'name' => 'supervisor_performance',
|
||||||
|
'name_fa' => 'عملکرد کارشناس ستاد',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,56 @@ class RoleSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$role = Role::query()->create([
|
$superAdmin = Role::query()->create([
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
'name' => 'super-admin',
|
'name' => 'super-admin',
|
||||||
'name_fa' => 'ادمین',
|
'name_fa' => 'سوپر ادمین',
|
||||||
'guard_name' => 'api',
|
'guard_name' => 'api',
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now()
|
'updated_at' => now()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$role->givePermissionTo(Permission::all());
|
$superAdmin->givePermissionTo(Permission::all());
|
||||||
User::query()->where('username', '=', 'witel')->first()->assignRole('super-admin');
|
User::query()->where('username', '=', 'witel')->first()->assignRole('super-admin');
|
||||||
|
|
||||||
|
$setadAdmin = Role::query()->create([
|
||||||
|
'id' => 2,
|
||||||
|
'name' => 'setad-admin',
|
||||||
|
'name_fa' => 'ادمین ستاد',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
$setadAdmin->givePermissionTo([1, 3, 4, 5, 6, 7, 8, 16]);
|
||||||
|
|
||||||
|
$setadExpert = Role::query()->create([
|
||||||
|
'id' => 3,
|
||||||
|
'name' => 'setad-expert',
|
||||||
|
'name_fa' => 'کارشناس ستاد',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
$setadExpert->givePermissionTo([3, 4, 5, 6, 7, 8]);
|
||||||
|
|
||||||
|
$provinceSupervisor = Role::query()->create([
|
||||||
|
'id' => 4,
|
||||||
|
'name' => 'province-supervisor',
|
||||||
|
'name_fa' => 'ارزیاب استان',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
$provinceSupervisor->givePermissionTo([3, 4, 9, 10, 11, 12]);
|
||||||
|
|
||||||
|
$province = Role::query()->create([
|
||||||
|
'id' => 5,
|
||||||
|
'name' => 'province',
|
||||||
|
'name_fa' => 'استان',
|
||||||
|
'guard_name' => 'api',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
$province->givePermissionTo([3, 12, 13, 14, 15]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,8 +214,7 @@ Route::middleware(['auth', 'permission:teleport_to_province'])
|
|||||||
Route::post('/', 'authenticate')->name('authenticate');
|
Route::post('/', 'authenticate')->name('authenticate');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware(['auth', 'setadIp'])
|
Route::prefix('verify_authentication')
|
||||||
->prefix('verify_authentication')
|
|
||||||
->name('verifyAuthentication.')
|
->name('verifyAuthentication.')
|
||||||
->controller(VerifyAuthenticationController::class)
|
->controller(VerifyAuthenticationController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
insert into provinces (id, name, lat, lon) values
|
insert into provinces (id, name, lat, lon, ip) values
|
||||||
('1','آذربایجان شرقی','38.0742000000','46.2962000000'),
|
('1','آذربایجان شرقی','38.0742000000','46.2962000000', '172.30.5.1'),
|
||||||
('2','آذربایجان غربی','37.5495000000','45.0683000000'),
|
('2','آذربایجان غربی','37.5495000000','45.0683000000', '172.30.5.1'),
|
||||||
('3','اردبیل','38.2419000000','48.2887000000'),
|
('3','اردبیل','38.2419000000','48.2887000000', '172.30.5.1'),
|
||||||
('4','اصفهان','32.6709000000','51.6650000000'),
|
('4','اصفهان','32.6709000000','51.6650000000', '172.30.5.1'),
|
||||||
('5','البرز','35.8124000000','51.0074000000'),
|
('5','البرز','35.8124000000','51.0074000000', '172.30.5.1'),
|
||||||
('6','ایرانشهر','27.2069903000','60.6882515000'),
|
('6','ایرانشهر','27.2069903000','60.6882515000', '172.30.5.1'),
|
||||||
('7','ایلام','33.6381000000','46.4203000000'),
|
('7','ایلام','33.6381000000','46.4203000000', '172.30.5.1'),
|
||||||
('8','بوشهر','28.9312000000','50.8458000000'),
|
('8','بوشهر','28.9312000000','50.8458000000', '172.30.5.1'),
|
||||||
('9','تهران','35.7065000000','51.3477000000'),
|
('9','تهران','35.7065000000','51.3477000000', '172.30.5.1'),
|
||||||
('10','چهارمحال و بختیاری','32.3259000000','50.8497000000'),
|
('10','چهارمحال و بختیاری','32.3259000000','50.8497000000', '172.30.5.1'),
|
||||||
('11','خراسان جنوبی','32.8635000000','59.2177000000'),
|
('11','خراسان جنوبی','32.8635000000','59.2177000000', '172.30.5.1'),
|
||||||
('12','خراسان رضوی','36.2977000000','59.6059000000'),
|
('12','خراسان رضوی','36.2977000000','59.6059000000', '172.30.5.1'),
|
||||||
('13','خراسان شمالی','37.4761000000','57.3320000000'),
|
('13','خراسان شمالی','37.4761000000','57.3320000000', '172.30.5.1'),
|
||||||
('14','خوزستان','31.3231000000','48.6793000000'),
|
('14','خوزستان','31.3231000000','48.6793000000', '172.30.5.1'),
|
||||||
('15','زنجان','36.6782000000','48.5079000000'),
|
('15','زنجان','36.6782000000','48.5079000000', '172.30.5.1'),
|
||||||
('16','سمنان شرق','36.4056260000','54.9670738726'),
|
('16','سمنان شرق','36.4056260000','54.9670738726', '172.30.5.1'),
|
||||||
('17','سمنان غرب','35.5834074000','53.3882906000'),
|
('17','سمنان غرب','35.5834074000','53.3882906000', '172.30.5.1'),
|
||||||
('18','سیستان و بلوچستان','29.4912000000','60.8674000000'),
|
('18','سیستان و بلوچستان','29.4912000000','60.8674000000', '172.30.5.1'),
|
||||||
('19','فارس','29.6061000000','52.5378000000'),
|
('19','فارس','29.6061000000','52.5378000000', '172.30.5.1'),
|
||||||
('20','قزوین','36.2816000000','50.0153000000'),
|
('20','قزوین','36.2816000000','50.0153000000', '172.30.5.1'),
|
||||||
('21','قم','34.6425000000','50.8801000000'),
|
('21','قم','34.6425000000','50.8801000000', '172.30.5.1'),
|
||||||
('22','کردستان','35.3128000000','46.9979000000'),
|
('22','کردستان','35.3128000000','46.9979000000', '172.30.5.1'),
|
||||||
('23','کرمان','30.2924085000','57.0645647000'),
|
('23','کرمان','30.2924085000','57.0645647000', '172.30.5.1'),
|
||||||
('24','کرمان جنوب','28.6697367000','57.7373382000'),
|
('24','کرمان جنوب','28.6697367000','57.7373382000', '172.30.5.1'),
|
||||||
('25','کرمانشاه','34.3241000000','47.0736000000'),
|
('25','کرمانشاه','34.3241000000','47.0736000000', '172.30.5.1'),
|
||||||
('26','کهگیلویه و بویراحمد','30.6678000000','51.5803000000'),
|
('26','کهگیلویه و بویراحمد','30.6678000000','51.5803000000', '172.30.5.1'),
|
||||||
('27','گلستان','36.8305000000','54.4242000000'),
|
('27','گلستان','36.8305000000','54.4242000000', '172.30.5.1'),
|
||||||
('28','گیلان','37.2795000000','49.5846000000'),
|
('28','گیلان','37.2795000000','49.5846000000', '172.30.5.1'),
|
||||||
('29','لارستان','27.6619203000','54.3229561000'),
|
('29','لارستان','27.6619203000','54.3229561000', '172.30.5.1'),
|
||||||
('30','لرستان','33.4844000000','48.3538000000'),
|
('30','لرستان','33.4844000000','48.3538000000', '172.30.5.1'),
|
||||||
('31','مازندران','36.5505000000','53.0708000000'),
|
('31','مازندران','36.5505000000','53.0708000000', '172.30.5.1'),
|
||||||
('32','مرکزی','34.0883000000','49.7132000000'),
|
('32','مرکزی','34.0883000000','49.7132000000', '172.30.5.1'),
|
||||||
('33','هرمزگان','27.1795000000','56.2781000000'),
|
('33','هرمزگان','27.1795000000','56.2781000000', '172.30.5.1'),
|
||||||
('34','همدان','34.7992000000','48.5148000000'),
|
('34','همدان','34.7992000000','48.5148000000', '172.30.5.1'),
|
||||||
('35','یزد','31.8888000000','54.3641000000');
|
('35','یزد','31.8888000000','54.3641000000', '172.30.5.1'),
|
||||||
|
('36','ستاد','35.7065000000','51.3477000000', '172.30.5.1');
|
||||||
|
|||||||
Reference in New Issue
Block a user