diff --git a/app/Domains/Auth/Models/ResetPasswordAttempt.php b/app/Domains/Auth/Models/ResetPasswordAttempt.php index fd331ae..d298def 100644 --- a/app/Domains/Auth/Models/ResetPasswordAttempt.php +++ b/app/Domains/Auth/Models/ResetPasswordAttempt.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Attributes\Hidden; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -#[Fillable(['user_id', 'codigo', 'reason', 'status'])] +#[Fillable(['user_id', 'codigo', 'reason', 'status', 'expires_at'])] #[Hidden(['codigo'])] class ResetPasswordAttempt extends Model { @@ -31,6 +31,7 @@ class ResetPasswordAttempt extends Model { return [ 'user_id' => 'integer', + 'expires_at' => 'datetime', ]; } diff --git a/database/migrations/2026_08_25_010000_add_expires_at_to_reset_password_attempts_table.php b/database/migrations/2026_08_25_010000_add_expires_at_to_reset_password_attempts_table.php new file mode 100644 index 0000000..c934b4b --- /dev/null +++ b/database/migrations/2026_08_25_010000_add_expires_at_to_reset_password_attempts_table.php @@ -0,0 +1,32 @@ +timestamp('expires_at')->nullable()->after('status'); + }); + + // Attempts created before this migration did not have an expiration instant. + DB::table('reset_password_attempts') + ->whereIn('status', [ + ResetPasswordAttempt::STATUS_PENDING, + ResetPasswordAttempt::STATUS_VALIDATED, + ]) + ->update(['status' => ResetPasswordAttempt::STATUS_EXPIRED]); + } + + public function down(): void + { + Schema::table('reset_password_attempts', function (Blueprint $table): void { + $table->dropColumn('expires_at'); + }); + } +};