mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Laravel Vapor - New schedule tasks and commands for token expiration for new user and password reset
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\ExpiresEmailVerificationAttempt;
|
||||
use App\Models\UserEmailVerification;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class NewUserRegistrationExpireCheckV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - New user email verification expiration check.');
|
||||
$start = new Carbon();
|
||||
|
||||
$attempts = UserEmailVerification::active()->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->email.', '.$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 . '.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\ExpiresPasswordReset;
|
||||
use App\Models\PasswordReset;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class PasswordResetTokenExpirationV2CommandJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
Log::info(Carbon::now() . ': Start job - Password reset token expiration check.');
|
||||
$start = new Carbon();
|
||||
|
||||
$attempts = PasswordReset::active()->oneDayOld()->get();
|
||||
|
||||
Log::info('PasswordReset Carbon now()->subHours(24): '. Carbon::now()->subHours(48));
|
||||
Log::info('PasswordReset Attempts count: '.count($attempts));
|
||||
|
||||
foreach ($attempts as $attempt){
|
||||
//(new ExpiresPasswordReset())->execute($attempt);
|
||||
Log::info('PasswordReset Expired: '.$attempt->email.', '.$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 . '.');
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
|
||||
use App\Classes\Jobs\Commands\V2\NewUserRegistrationExpireCheckV2CommandJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class NewUserRegistrationExpireCheckV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'new-user-registration-expire-check-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'New user email verification expiration check.';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
NewUserRegistrationExpireCheckV2CommandJob::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\V2;
|
||||
|
||||
|
||||
use App\Classes\Jobs\Commands\V2\PasswordResetTokenExpirationV2CommandJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PasswordResetTokenExpirationV2Command extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'password-reset-token-expriration-check-command';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Password reset token expiration check.';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
PasswordResetTokenExpirationV2CommandJob::dispatch();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,14 @@ class Kernel extends ConsoleKernel
|
||||
->dailyAt('01:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('password-reset-token-expriration-check-command')
|
||||
->everyFiveMinutes()
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('new-user-registration-expire-check-command')
|
||||
->everyFiveMinutes()
|
||||
->withoutOverlapping();
|
||||
|
||||
if(env('APP_ENV') === 'production'){
|
||||
$schedule->command('curl-vt-command')
|
||||
->cron('0 8 * * *')
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user