diff --git a/app/Http/Controllers/AuthenticateSessionController.php b/app/Http/Controllers/AuthenticateSessionController.php
index 58fb4374..61cc4a9e 100644
--- a/app/Http/Controllers/AuthenticateSessionController.php
+++ b/app/Http/Controllers/AuthenticateSessionController.php
@@ -21,9 +21,7 @@ public function authenticate(AuthenticateSessionRequest $request): RedirectRespo
if (auth()->attempt($credentials)) {
$request->session()->regenerate();
- return $request->user()->hasRole(["admin", "super_admin"])
- ? Redirect::route("admin.quizzes.index")
- : Redirect::route("dashboard");
+ return redirect()->route("home");
}
throw ValidationException::withMessages([
diff --git a/app/Http/Controllers/ContestController.php b/app/Http/Controllers/ContestController.php
index e5ffac73..5d595d44 100644
--- a/app/Http/Controllers/ContestController.php
+++ b/app/Http/Controllers/ContestController.php
@@ -9,6 +9,7 @@
use App\Http\Resources\UserQuizResource;
use App\Models\Quiz;
use App\Models\School;
+use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
@@ -22,9 +23,14 @@ public function index(): Response
return Inertia::render("Home", ["schools" => SchoolResource::collection($schools)]);
}
- public function create(Request $request): Response
+ public function create(Request $request): RedirectResponse|Response
{
$user = $request->user();
+
+ if ($user->hasRole(["admin", "super_admin"])) {
+ return redirect()->route("admin.quizzes.index");
+ }
+
$userQuizzes = $user->userQuizzes()
->with(["userQuestions.question.answers", "quiz"])
->get();
diff --git a/resources/js/Layouts/AdminLayout.vue b/resources/js/Layouts/AdminLayout.vue
deleted file mode 100644
index 5c121114..00000000
--- a/resources/js/Layouts/AdminLayout.vue
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
diff --git a/resources/js/Layouts/BaseLayout.vue b/resources/js/Layouts/BaseLayout.vue
index 13d691b2..3460e3e8 100644
--- a/resources/js/Layouts/BaseLayout.vue
+++ b/resources/js/Layouts/BaseLayout.vue
@@ -6,7 +6,7 @@ import Banner from '@/components/Common/Banner.vue'
import {ref, watch} from 'vue'
import {type PageProps} from '@/Types/PageProps'
-const props = defineProps<{ pages: Page[] } & PageProps>()
+const props = defineProps()
const status = ref(props.flash.status)
watch(() => props.flash, flash => {
@@ -17,6 +17,26 @@ function hideMessage() {
status.value = undefined
}
+const pages: Page[] = []
+
+if (!!props.user?.isAdmin || props.user?.isSuperAdmin) {
+ pages.push(
+ { title: 'Testy', href: '/admin/quizzes' },
+ { title: 'Szkoły', href: '/admin/schools' },
+ { title: 'Uczniowie', href: '/admin/users' },
+ )
+}
+else {
+ pages.push({ title: 'Konkursy', href: '/dashboard' })
+}
+
+pages.push(
+ { title: 'Profil', href: '/profile' },
+)
+
+if (props.user?.isSuperAdmin) {
+ pages.push({ title: 'Administratorzy', href: '/admin/admins'})
+}
diff --git a/resources/js/Layouts/UserLayout.vue b/resources/js/Layouts/UserLayout.vue
deleted file mode 100644
index b362a5b0..00000000
--- a/resources/js/Layouts/UserLayout.vue
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
diff --git a/resources/js/app.ts b/resources/js/app.ts
index 55845f72..5629b9a6 100644
--- a/resources/js/app.ts
+++ b/resources/js/app.ts
@@ -2,8 +2,7 @@ import '../css/app.css'
import { createApp, h, type DefineComponent } from 'vue'
import { createInertiaApp } from '@inertiajs/vue3'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
-import UserLayout from '@/Layouts/UserLayout.vue'
-import AdminLayout from '@/Layouts/AdminLayout.vue'
+import BaseLayout from '@/Layouts/BaseLayout.vue'
import GuestLayout from '@/Layouts/GuestLayout.vue'
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
@@ -22,12 +21,8 @@ createInertiaApp({
import.meta.glob('./Pages/**/*.vue'),
)
- if (name.startsWith('Admin/')) {
- page.default.layout ??= AdminLayout
- }
-
- if (name.startsWith('User/')) {
- page.default.layout ??= UserLayout
+ if (name.startsWith('Admin/') || name.startsWith('User/')) {
+ page.default.layout ??= BaseLayout
}
if (name.startsWith('Guest/')) {
diff --git a/tests/Feature/AuthenticateSessionTest.php b/tests/Feature/AuthenticateSessionTest.php
index e4078dd9..d61b9b4f 100644
--- a/tests/Feature/AuthenticateSessionTest.php
+++ b/tests/Feature/AuthenticateSessionTest.php
@@ -20,7 +20,7 @@ public function testUserCanLogin(): void
"email" => "test@example.com",
"password" => "goodPassword",
])
- ->assertRedirect("/dashboard");
+ ->assertRedirect("/");
}
public function testUserCanNotLoginWithWrongPassword(): void
@@ -66,7 +66,7 @@ public function testUnverifiedUserCanLogin(): void
"email" => "test@example.com",
"password" => "goodPassword",
])
- ->assertRedirect("/dashboard");
+ ->assertRedirect("/");
}
public function testUnverifiedUserIsRedirectedToVerifyEmail(): void
diff --git a/tests/Feature/ResetPasswordTest.php b/tests/Feature/ResetPasswordTest.php
index a413e7a7..3450f9d2 100644
--- a/tests/Feature/ResetPasswordTest.php
+++ b/tests/Feature/ResetPasswordTest.php
@@ -45,7 +45,7 @@ public function testUserCanResetPasswordWithValidToken(): void
"password" => "newPassword",
]);
- $loginResponse->assertRedirect("/dashboard");
+ $loginResponse->assertRedirect("/");
$this->assertAuthenticated();
Event::assertDispatched(PasswordReset::class);
}