diff --git a/compat/auth/laravel/authcontroller/LauncherAuthController.php b/compat/auth/laravel/authcontroller/LauncherAuthController.php new file mode 100644 index 00000000..6c41adc4 --- /dev/null +++ b/compat/auth/laravel/authcontroller/LauncherAuthController.php @@ -0,0 +1,36 @@ +getContent()); + + if ($data->apiKey !== env('LAUNCHER_APIKEY')) { + return response()->json([ + 'error' => 'Неверный ключ. Обратитесь к администратору', + ]); + } + + if (Auth::attempt(['name' => $data->username, 'password' => $data->password])) { + $perm = DB::table('users') + ->select('launcher_permission') + ->where('name', '=', $data->username) + ->first(); + + return response()->json([ + 'username' => $data->username, + 'permission' => $perm->launcher_permission, + ]); + } else { + return response()->json([ + 'error' => 'Неверный логин или пароль', + ]); + } + } +} diff --git a/compat/auth/laravel/authcontroller/README.MD b/compat/auth/laravel/authcontroller/README.MD new file mode 100644 index 00000000..d09d30bd --- /dev/null +++ b/compat/auth/laravel/authcontroller/README.MD @@ -0,0 +1,9 @@ +#Контроллер авторизации методом json + +Route: +```php +Route::put('launcher/auth', 'LauncherAuthController@json'); +``` + +Добавить в **.env** строку `LAUNCHER_APIKEY=none` +Где `none` ваш apiKey \ No newline at end of file diff --git a/compat/auth/laravel/authcontroller/migrations/2020_03_05_151322_add_permission_collum.php b/compat/auth/laravel/authcontroller/migrations/2020_03_05_151322_add_permission_collum.php new file mode 100644 index 00000000..d82e5eb2 --- /dev/null +++ b/compat/auth/laravel/authcontroller/migrations/2020_03_05_151322_add_permission_collum.php @@ -0,0 +1,32 @@ +integer('launcher_permission')->default('0'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('launcher_permission'); + }); + } +} diff --git a/compat/auth/laravel/migrations/2020_03_04_172425_create_hwid_table.php b/compat/auth/laravel/migrations/2020_03_04_172425_create_hwid_table.php new file mode 100644 index 00000000..db0c8b9f --- /dev/null +++ b/compat/auth/laravel/migrations/2020_03_04_172425_create_hwid_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->tinyInteger('isBanned')->default('0'); + $table->text('totalMemory'); + $table->text('serialNumber'); + $table->text('HWDiskSerial'); + $table->text('processorID'); + $table->text('macAddr'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('users_hwids'); + } +} diff --git a/compat/auth/laravel/migrations/2020_03_05_140131_add_auth_handler_collums.php b/compat/auth/laravel/migrations/2020_03_05_140131_add_auth_handler_collums.php new file mode 100644 index 00000000..8a456f60 --- /dev/null +++ b/compat/auth/laravel/migrations/2020_03_05_140131_add_auth_handler_collums.php @@ -0,0 +1,36 @@ +char('uuid', '36')->unique()->nullable(); + $table->char('accessToken', '32')->nullable(); + $table->string('serverID', '41')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('uuid'); + $table->dropColumn('accessToken'); + $table->dropColumn('serverID'); + }); + } +} diff --git a/compat/auth/laravel/migrations/2020_03_05_142041_add_hwid_handler_collums.php b/compat/auth/laravel/migrations/2020_03_05_142041_add_hwid_handler_collums.php new file mode 100644 index 00000000..5040340b --- /dev/null +++ b/compat/auth/laravel/migrations/2020_03_05_142041_add_hwid_handler_collums.php @@ -0,0 +1,32 @@ +bigInteger('hwid')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('hwid'); + }); + } +} diff --git a/compat/auth/laravel/migrations/README.MD b/compat/auth/laravel/migrations/README.MD new file mode 100644 index 00000000..856151ac --- /dev/null +++ b/compat/auth/laravel/migrations/README.MD @@ -0,0 +1 @@ +# Миграции для Laravel \ No newline at end of file