Add encrypted Etsy app credential settings
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 23s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 23s
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\EtsyAppCredential;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<EtsyAppCredential>
|
||||
*/
|
||||
class EtsyAppCredentialFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'keystring' => fake()->bothify('etsy-key-????????'),
|
||||
'shared_secret' => fake()->sha256(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('etsy_app_credentials', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('keystring');
|
||||
$table->text('shared_secret');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('etsy_app_credentials');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\EtsyAppCredential;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class EtsyAppCredentialSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$keystring = config('services.etsy.keystring');
|
||||
$sharedSecret = config('services.etsy.shared_secret');
|
||||
|
||||
if (filled($keystring) && filled($sharedSecret)) {
|
||||
if (EtsyAppCredential::find(1) === null) {
|
||||
$credentials = new EtsyAppCredential;
|
||||
$credentials->id = 1;
|
||||
$credentials->keystring = $keystring;
|
||||
$credentials->shared_secret = $sharedSecret;
|
||||
$credentials->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user