diff --git a/app/Classes/Jobs/Commands/V2/NewUserRegistrationExpireCheckV2CommandJob.php b/app/Classes/Jobs/Commands/V2/NewUserRegistrationExpireCheckV2CommandJob.php new file mode 100644 index 00000000..3170611a --- /dev/null +++ b/app/Classes/Jobs/Commands/V2/NewUserRegistrationExpireCheckV2CommandJob.php @@ -0,0 +1,38 @@ +twoDaysOld()->get(); + + Log::info('NewUser Carbon now()->subHours(48): '. Carbon::now()->subHours(48)); + Log::info('NewUser Attempts count: '.count($attempts)); + + foreach ($attempts as $attempt){ + (new ExpiresEmailVerificationAttempt())->execute($attempt); + Log::info('NewUser Expired: '.$attempt->id.', '.$attempt->created_at); + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + Log::info(Carbon::now() . ': End job - New user email verification expiration check. ElapsedTime: ' . $elapsedTime . '.'); + } +} diff --git a/app/Classes/Jobs/Commands/V2/PasswordResetTokenExpirationV2CommandJob.php b/app/Classes/Jobs/Commands/V2/PasswordResetTokenExpirationV2CommandJob.php new file mode 100644 index 00000000..93049f5e --- /dev/null +++ b/app/Classes/Jobs/Commands/V2/PasswordResetTokenExpirationV2CommandJob.php @@ -0,0 +1,38 @@ +oneDayOld()->get(); + + Log::info('PasswordReset Carbon now()->subHours(24): '. Carbon::now()->subHours(24)); + Log::info('PasswordReset Attempts count: '.count($attempts)); + + foreach ($attempts as $attempt){ + (new ExpiresPasswordReset())->execute($attempt); + Log::info('PasswordReset Expired: '.$attempt->id.', '.$attempt->created_at); + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + Log::info(Carbon::now() . ': End job - Password reset token expiration check. ElapsedTime: ' . $elapsedTime . '.'); + } +} diff --git a/app/Classes/Modules/Accounts/ControllersLogic/GeneratePasswordResetLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/GeneratePasswordResetLogic.php index f3255138..b397041b 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/GeneratePasswordResetLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/GeneratePasswordResetLogic.php @@ -77,7 +77,7 @@ class GeneratePasswordResetLogic extends AbstractControllerLogic $attempt = $this->generatesPasswordReset->execute($user); - // $this->passwordResetTokenExpiration::dispatch($attempt)->delay(now()->addHours(24)); // cief todo: to convert to schedule task + // $this->passwordResetTokenExpiration::dispatch($attempt)->delay(now()->addHours(24)); //converted to schedule task $this->sendResetPasswordEmail::dispatch($user, $attempt); return $this->response(['email' => $object->getEmail()]); diff --git a/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php b/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php index bd15c786..18531684 100644 --- a/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php +++ b/app/Classes/Modules/Accounts/Processors/GenerateEmailVerificationAttemptProcessor.php @@ -50,7 +50,7 @@ class GenerateEmailVerificationAttemptProcessor $attempt = $this->generatesEmailVerificationAttempt->execute($user); - //$this->emailVerificationAttemptExpiration::dispatch($attempt)->delay(now()->addHours(48)); // cief todo: to convert to schedule task + //$this->emailVerificationAttemptExpiration::dispatch($attempt)->delay(now()->addHours(48)); //converted to schedule task $this->sendUserVerificationEmail::dispatch($user, $attempt); diff --git a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzDataPatchProcessor.php b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzDataPatchProcessor.php index 9843a0d9..7bbd0e82 100644 --- a/app/Classes/Modules/Billplzs/Processors/CallbackBillplzDataPatchProcessor.php +++ b/app/Classes/Modules/Billplzs/Processors/CallbackBillplzDataPatchProcessor.php @@ -130,8 +130,8 @@ class CallbackBillplzDataPatchProcessor } else{ - Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed - Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed + Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); + Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); return false; } } diff --git a/app/Console/Commands/V2/NewUserRegistrationExpireCheckV2Command.php b/app/Console/Commands/V2/NewUserRegistrationExpireCheckV2Command.php new file mode 100644 index 00000000..a74b6bf5 --- /dev/null +++ b/app/Console/Commands/V2/NewUserRegistrationExpireCheckV2Command.php @@ -0,0 +1,46 @@ +dailyAt('01:00') ->withoutOverlapping(); + $schedule->command('password-reset-token-expriration-check-command') + ->everySixHours() + ->withoutOverlapping(); + + $schedule->command('new-user-registration-expire-check-command') + ->everySixHours() + ->withoutOverlapping(); + if(env('APP_ENV') === 'production'){ $schedule->command('curl-vt-command') ->cron('0 8 * * *') diff --git a/app/Models/PasswordReset.php b/app/Models/PasswordReset.php index 6ab27179..e22e85a0 100644 --- a/app/Models/PasswordReset.php +++ b/app/Models/PasswordReset.php @@ -2,6 +2,7 @@ namespace App\Models; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Relations\BelongsTo; class PasswordReset extends AbstractModel @@ -22,4 +23,13 @@ class PasswordReset extends AbstractModel public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id', 'id'); } + + /** + * @param $query + * @return mixed + */ + public function scopeOneDayOld($query) + { + return $query->where('created_at', '<=', Carbon::now()->subHours(24)); + } } diff --git a/app/Models/UserEmailVerification.php b/app/Models/UserEmailVerification.php index 278c8cd6..a89627af 100644 --- a/app/Models/UserEmailVerification.php +++ b/app/Models/UserEmailVerification.php @@ -2,6 +2,7 @@ namespace App\Models; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Relations\BelongsTo; class UserEmailVerification extends AbstractModel @@ -25,4 +26,13 @@ class UserEmailVerification extends AbstractModel public function user(): BelongsTo { return $this->belongsTo(User::class, 'email', 'email'); } + + /** + * @param $query + * @return mixed + */ + public function scopeTwoDaysOld($query) + { + return $query->where('created_at', '<=', Carbon::now()->subHours(48)); + } }