From 37b7dabb15c5fc683549bfd712e9777de60890c7 Mon Sep 17 00:00:00 2001 From: Mufassil Yasir Date: Fri, 30 Jun 2023 12:14:18 +0500 Subject: [PATCH] bug fix --- app/Http/Controllers/Auth/AuthController.php | 16 +++++++++------- app/Jobs/ProcessRosterInactivity.php | 8 +++----- app/Models/Users/User.php | 3 --- app/Notifications/Roster/RemovedFromRoster.php | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 61ff533d..217982d3 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -2,17 +2,18 @@ namespace App\Http\Controllers\Auth; -use App\Http\Controllers\Controller; +use GuzzleHttp\Client; use App\Models\Users\User; -use App\Models\Users\UserNotificationPreferences; +use Illuminate\Support\Str; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; +use App\Http\Controllers\Controller; +use Illuminate\Support\Facades\Auth; use App\Models\Users\UserPreferences; -use App\Models\Users\UserPrivacyPreferences; -use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; +use App\Models\Users\UserPrivacyPreferences; +use App\Models\Users\UserNotificationPreferences; use Illuminate\Foundation\Auth\AuthenticatesUsers; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Str; /** * Class AuthController. @@ -131,6 +132,7 @@ public function validateConnectLogin(Request $request) $notif->save(); } + Log::info($user->id.' logged in'); return redirect()->route('my.index')->with('success', "Welcome back, {$user->fullName('F')}!"); } } diff --git a/app/Jobs/ProcessRosterInactivity.php b/app/Jobs/ProcessRosterInactivity.php index 5072b653..69f58b00 100644 --- a/app/Jobs/ProcessRosterInactivity.php +++ b/app/Jobs/ProcessRosterInactivity.php @@ -51,16 +51,13 @@ public function handle() } if ($date === false){ - if ($certifiedDate > Carbon::now()->startOfQuarter() && $certifiedDate < Carbon::now()->endOfQuarter()){ + if ($certifiedDate > Carbon::now()->subDays(2)->startOfQuarter() && $certifiedDate < Carbon::now()->subDays(2)->endOfQuarter()){ continue; } } if ($rosterMember->active) { if ($rosterMember->currency < 6.0) { - $rosterMember->active = false; - $rosterMember->save(); - $discord = new DiscordClient(); $discord_user_id = $rosterMember->user->discord_user_id; if ($discord_user_id && $rosterMember->user->member_of_czqo){ @@ -69,7 +66,8 @@ public function handle() } $rosterMember->user->removeRole('Certified Controller'); $rosterMember->user->assignRole('Guest'); - Notification::send($rosterMember->user, new RosterStatusChanged($rosterMember)); + Notification::send($rosterMember->user, new RemovedFromRoster($rosterMember)); + $rosterMember->delete(); } }elseif (!$rosterMember->active) { $rosterMember->delete(); diff --git a/app/Models/Users/User.php b/app/Models/Users/User.php index 0e990657..23e5bbb3 100644 --- a/app/Models/Users/User.php +++ b/app/Models/Users/User.php @@ -241,9 +241,6 @@ public function highestRole() if (count($this->roles) == 0) { //Assign them guest $this->assignRole('Guest'); - - //Should probably inform - Log::alert('User '.$this->id.' did not have any role assigned. Guest role assigned.'); } return $this->roles[0]; diff --git a/app/Notifications/Roster/RemovedFromRoster.php b/app/Notifications/Roster/RemovedFromRoster.php index ce9dd052..69df79c0 100644 --- a/app/Notifications/Roster/RemovedFromRoster.php +++ b/app/Notifications/Roster/RemovedFromRoster.php @@ -7,7 +7,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; -class RemovedFromRoster extends Notification implements ShouldQueue +class RemovedFromRoster extends Notification { use Queueable; protected $user;