Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP add Auth #40

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,7 @@ class Kernel extends HttpKernel
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'terminal' => \App\Http\Middleware\TerminalMiddleWare::class,
'admin' => \App\Http\Middleware\AdminMiddleWare::class,
];
}
26 changes: 13 additions & 13 deletions src/app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ public function version(Request $request): ?string
return parent::version($request);
}

/**
* Defines the props that are shared by default.
*
* @see https://inertiajs.com/shared-data
* @param \Illuminate\Http\Request $request
* @return array
*/
public function share(Request $request): array
{
return array_merge(parent::share($request), [
//
]);
}
/**
* Defines the props that are shared by default.
*
* @see https://inertiajs.com/shared-data
* @param \Illuminate\Http\Request $request
* @return array
*/
public function share(Request $request): array
{
return array_merge(parent::share($request), [
'user' => fn() => auth()->user()
]);
}
}
16 changes: 9 additions & 7 deletions src/resources/vue/pages/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,21 @@

<script>
import AdminLayout from "../../layouts/admin-layout.vue";
import { computed } from 'vue'
import { usePage } from '@inertiajs/vue3'

export default {
name: "admin-index",
components: {
AdminLayout,
},
setup() {
const page = usePage()
const userData = computed(() => page.props.user)

return {userData}
},
props: {
userData: {
type: Object,
required: true,
default: () => ({
name: "John Doe",
}),
},
count: {
type: Object,
required: true,
Expand Down
7 changes: 5 additions & 2 deletions src/resources/vue/pages/admin/items/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<AdminLayout >
<AdminLayout :user-data="userData" >
<div class="content">
<div class="header">
<h1>Items</h1>
Expand Down Expand Up @@ -39,6 +39,7 @@ import AdminLayout from "@layouts/admin-layout.vue";
import Pagination from "@components/admin/pagination.vue";
import { computed } from 'vue'
import { usePage } from '@inertiajs/vue3'

export default {
name: "admin-items-index",
components: {
Expand All @@ -48,7 +49,9 @@ export default {
setup() {
const page = usePage();
const items = computed(() => page.props.items);
return {items};
const userData = computed(() => page.props.user);

return {items, userData};
}
}
</script>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
Route::get('/', [IndexController::class, 'index']);


Route::get('/admin', [AdminController::class, 'index']);
Route::get('/admin/items', [AdminController::class, 'items']);
Route::get('/admin', [AdminController::class, 'index'])->middleware('admin');
Route::get('/admin/items', [AdminController::class, 'items'])->middleware('admin');
Route::get('/terminal', [AppController::class, 'index']);

Route::post('/auth', [SessionController::class, 'auth'])->name('auth');
Loading