Page MenuHomePhorge

D2773.1775521278.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D2773.1775521278.diff

diff --git a/src/app/AuthAttempt.php b/src/app/AuthAttempt.php
--- a/src/app/AuthAttempt.php
+++ b/src/app/AuthAttempt.php
@@ -43,6 +43,9 @@
'last_seen' => 'datetime'
];
+ public $incrementing = false;
+ protected $keyType = 'string';
+
/**
* Prepare a date for array / JSON serialization.
*
diff --git a/src/app/Observers/AuthAttemptObserver.php b/src/app/Observers/AuthAttemptObserver.php
new file mode 100644
--- /dev/null
+++ b/src/app/Observers/AuthAttemptObserver.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Observers;
+
+use App\AuthAttempt;
+
+/**
+ * This is an observer for the AuthAttempt model definition.
+ */
+class AuthAttemptObserver
+{
+ /**
+ * Handle the "creating" event on an AuthAttempt.
+ *
+ * Ensures that the entry uses a custom ID (uuid).
+ *
+ * @param AuthAttempt $authAttempt The AuthAttempt being created.
+ *
+ * @return void
+ */
+ public function creating(AuthAttempt $authAttempt)
+ {
+ while (true) {
+ $allegedly_unique = \App\Utils::uuidStr();
+ if (!AuthAttempt::find($allegedly_unique)) {
+ $authAttempt->{$authAttempt->getKeyName()} = $allegedly_unique;
+ break;
+ }
+ }
+ }
+}
diff --git a/src/app/Providers/AppServiceProvider.php b/src/app/Providers/AppServiceProvider.php
--- a/src/app/Providers/AppServiceProvider.php
+++ b/src/app/Providers/AppServiceProvider.php
@@ -44,6 +44,7 @@
*/
public function boot()
{
+ \App\AuthAttempt::observe(\App\Observers\AuthAttemptObserver::class);
\App\Discount::observe(\App\Observers\DiscountObserver::class);
\App\Domain::observe(\App\Observers\DomainObserver::class);
\App\Entitlement::observe(\App\Observers\EntitlementObserver::class);
diff --git a/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php b/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php
--- a/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php
+++ b/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php
@@ -15,7 +15,7 @@
public function up()
{
Schema::create('auth_attempts', function (Blueprint $table) {
- $table->bigIncrements('id');
+ $table->uuid('id')->primary();
$table->bigInteger('user_id');
$table->string('ip', 36);
$table->string('status', 36)->default('NEW');

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 7, 12:21 AM (10 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18833287
Default Alt Text
D2773.1775521278.diff (2 KB)

Event Timeline