you say which is better, but you only showed one approach. You cannot remove expiration time from the table because this needs to hold the timestamp of when their 2fa code will no longer be valid
Mar 3, 2024
4
Level 2
Handle OTP Expiration Time
Hello guys , i'm creating user verification using an SMS sent his/her phone and this is my database table for it:
Schema::create('otps', function (Blueprint $table) {
$table->id();
$table->string('code', 6);
$table->boolean('is_verified')->default(false);
$table->foreignId('user_id')->nullable()->constrained('users')->cascadeOnDelete();
$table->timestampTz('expires_at');
$table->softDeletes();
$table->timestampsTz();
and i am thinking of replacing the expires_at column with a separate config file that holds the expiration time like this:
<?php
return [
'expiration_time' => env('OTP_EXPIRATION_TIME', 15),
];
which approach is better?
Please or to participate in this conversation.