diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 2f772ea..23eb236 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -14,7 +14,8 @@ class AuthController extends Controller { public function show() { - return Inertia::render('Auth/Login'); + return $this->login(); + //return Inertia::render('Auth/Login'); } public function login() @@ -42,11 +43,10 @@ public function loginCallback() $regId = $attendeeListResponse['ids'][0] ?? null; - /*if (isset($attendeeListResponse['ids'][0]) === false) { + if (isset($attendeeListResponse['ids'][0]) === false) { return redirect()->route('welcome')->with('message', 'Please register for the Convention first before trying to obtain a fursuit badge.'); - }*/ - //$regId = $attendeeListResponse['ids'][0]; + } $user = User::updateOrCreate([ 'remote_id' => $socialLiteUser->getId(), @@ -60,7 +60,7 @@ public function loginCallback() $user->wallet->balance; - /*$statusResponse = \Illuminate\Support\Facades\Http::attsrv() + $statusResponse = \Illuminate\Support\Facades\Http::attsrv() ->withToken($socialLiteUser->token) ->get('/attendees/'.$regId.'/status'); @@ -68,7 +68,7 @@ public function loginCallback() if (in_array($statusResponse->json()['status'], ['paid', 'checked in'])) { $user->valid_registration = true; $user->save(); - }*/ + } (new TokenRefreshService($user))->save( accessToken: $socialLiteUser->token, @@ -76,7 +76,11 @@ public function loginCallback() expiresIn: 3500 ); - Auth::login($user); + Auth::login($user, true); + if(Session::exists('catch-em-all-redirect')) { + Session::forget('catch-em-all-redirect'); + return redirect()->route('fcea.dashboard'); + } return redirect()->route('dashboard'); } diff --git a/app/Http/Controllers/FCEA/DashboardController.php b/app/Http/Controllers/FCEA/DashboardController.php index 43f4061..60a2184 100644 --- a/app/Http/Controllers/FCEA/DashboardController.php +++ b/app/Http/Controllers/FCEA/DashboardController.php @@ -40,10 +40,31 @@ public function index() } return Inertia::render('FCEA/Dashboard', [ - 'myUserInfo' => $myUserInfo, - 'userRanking' => $userRanking, + 'myUserInfo' => [ + 'id' => $myUserInfo->id, + 'rank' => $myUserInfo->rank, + 'score' => $myUserInfo->score, + 'score_till_next' => $myUserInfo->score_till_next, + 'others_behind' => $myUserInfo->others_behind, + ], + 'userRanking' => $userRanking + ->filter(fn($e) => $e->score > 0) + ->map(function ($entry) { + return [ + 'id' => $entry->id, + 'rank' => $entry->rank, + 'score' => $entry->score, + 'score_till_next' => $entry->score_till_next, + 'others_behind' => $entry->others_behind, + 'user' => [ + 'name' => $entry->user->name, + ], + ]; + }), 'myFursuitInfos' => $myFursuitInfos, - 'fursuitRanking' => $fursuitRanking, + 'fursuitRanking' => $fursuitRanking->map(fn($entry) => [ + 'name' => $entry->fursuit->name, + ]), 'myFursuitInfoCatchedTotal' => $myFursuitInfoCatchedTotal, // How many times the user got catched on all fursuits summed up 'caughtFursuit' => $caughtFursuit ]); @@ -107,11 +128,6 @@ public static function refreshRanking() { self::refreshFursuitRanking(); } - public function refreshRanking() { - $this->refreshUserRanking(); - $this->refreshFursuitRanking(); - } - // Function to build User Ranking. Truncated Table and iterates all users. Similar to the Fursuit Ranking public static function refreshUserRanking() { $usersOrdered = User::query() diff --git a/resources/js/Layouts/CatchEmAllLayout.vue b/resources/js/Layouts/CatchEmAllLayout.vue new file mode 100644 index 0000000..4c055d3 --- /dev/null +++ b/resources/js/Layouts/CatchEmAllLayout.vue @@ -0,0 +1,48 @@ + + + diff --git a/resources/js/Pages/FCEA/Dashboard.vue b/resources/js/Pages/FCEA/Dashboard.vue index c393dbc..033627c 100644 --- a/resources/js/Pages/FCEA/Dashboard.vue +++ b/resources/js/Pages/FCEA/Dashboard.vue @@ -1,14 +1,16 @@ diff --git a/routes/web.php b/routes/web.php index c2e8bfb..48cfcac 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,3 +22,5 @@ Route::resource('badges', \App\Http\Controllers\BadgeController::class); }); }); + +Route::permanentRedirect('/catch-em-all', '/fcea/');