Merge branch 'master' into fix/headerauth-crash-missing-header

This commit is contained in:
Benjamyn Love 2023-10-11 00:56:48 -04:00
commit b03ad75e9e
13 changed files with 81 additions and 55 deletions

View File

@ -54,6 +54,7 @@ class Kernel extends HttpKernel
*/
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.admin' => \App\Http\Middleware\AuthenticateAdmin::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,

View File

@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class AuthenticateAdmin
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (!auth()->user()->is_admin) {
return response('Unauthorized', 401);
}
return $next($request);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,4 @@
{{-- https://heroicons.com/ --}}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" />
</svg>

View File

@ -0,0 +1,4 @@
{{-- https://heroicons.com/ --}}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
</svg>

View File

@ -2,7 +2,12 @@
<a {{ $attributes }} class="
{{ Route::is($route)
? 'text-nexi-red bg-gray-50 dark:text-nexi-purple dark:bg-zinc-800 transition-colors duration-300'
: 'text-nexi-black dark:text-nexi-grey hover:text-nexi-red dark:hover:text-nexi-red hover:bg-gray-100 dark:hover:bg-zinc-500 transition-colors duration-300' }}
group flex items-center px-2 py-2 text-base font-medium rounded-md"
>{{ $slot }}</a>
? 'text-nexi-red bg-gray-50 dark:bg-zinc-800 transition-colors duration-300'
: 'text-nexi-black dark:text-nexi-grey hover:text-nexi-red dark:hover:text-nexi-red hover:bg-gray-400 dark:hover:bg-zinc-700 transition-colors duration-300' }}
group flex gap-x-3 leading-6 items-center p-2 text-base font-medium rounded-md"
wire:navigate>
{{ $svg ?? '' }}
<span>
{{ $slot }}
</span>
</a>

View File

@ -1,51 +1,38 @@
<div>
<div class="flex h-16 shrink-0 items-center border-b border-gray-200">
<a href="{{ route('home') }}" wire:navigate>
<img class="h-12 w-auto" src="https://benjamyn.love/PriceyBot.png" alt="">
<img class="h-12 w-auto rounded" src="{{ asset('images/PriceyBot.webp') }}" alt="all hail pricey bot">
</a>
</div>
<nav class="flex flex-1 flex-col">
<ul role="list" class="flex flex-1 flex-col gap-y-7">
<li class="border-b border-gray-200">
<li class="border-b border-gray-200 pb-1">
<div class="text-xs font-semibold leading-6 text-gray-400">User Menu</div>
<ul role="list" class="-mx-2 mt-2 space-y-1">
<ul role="list" class="-mx-2 space-y-1">
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
{{-- <svg class="h-6 w-6 shrink-0 text-indigo-600" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">--}}
{{-- <path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />--}}
{{-- </svg>--}}
<x-sidebar-nav :href="route('dashboard')" route="dashboard">First Page</x-sidebar-nav>
</li>
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
{{-- <x-sidebar-nav :href="route('u-2')" route="u-2">Second Page</x-sidebar-nav>--}}
</li>
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
{{-- <x-sidebar-nav :href="route('u-3')" route="u-3">Third Page</x-sidebar-nav>--}}
<li >
<x-sidebar-nav :href="route('dashboard')" route="dashboard">
<x-slot:svg><x-icons.home/></x-slot:svg>
First Page
</x-sidebar-nav>
</li>
</ul>
</ul>
</li>
@if(auth()->user()->is_admin)
<li>
<li class="border-b border-gray-200 pb-1">
<div class="text-xs font-semibold leading-6 text-gray-400">Admin Menu</div>
<ul role="list" class="-mx-2 mt-2 space-y-1">
<ul role="list" class="-mx-2 space-y-1">
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
<x-sidebar-nav :href="route('admin.send')" route="send">Send Quote</x-sidebar-nav>
</li>
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
{{-- <x-sidebar-nav :href="route('a-2')" route="a-2">Second Page</x-sidebar-nav>--}}
</li>
<li>
{{-- TODO: fill with SVG icons to make it pretty --}}
{{-- <x-sidebar-nav :href="route('a-3')" route="a-3">Third Page</x-sidebar-nav>--}}
<x-sidebar-nav :href="route('admin.send')" route="admin.send">
<x-slot:svg><x-icons.chat-bubble/></x-slot:svg>
Send Quote
</x-sidebar-nav>
</li>
</ul>
</ul>
</li>
@endif
</ul>

View File

@ -1,5 +1,5 @@
<x-guest-layout>
<div class="flex flex-col mt-8">
<div class="flex flex-col mt-8 mb-8">
<livewire:pages.quote.request/>
<livewire:pages.quote.requested/>

View File

@ -21,7 +21,6 @@
<body class="antialiased bg-nexi-primary dark:bg-nexi-primary-dark font-sans text-nexi-black transition-colors duration-300 h-full">
<div x-data="{ sidebarOpen: false }">
<div class="relative z-50 lg:hidden" role="dialog" aria-modal="true">
{{-- TODO: Look into why the fuck does this not work? mobile views seem to not work with livewire clicks??? --}}
<div x-show="sidebarOpen"
x-transition:enter="transition-opacity ease-linear duration-300"
x-transition:enter-start="opacity-0"

View File

@ -19,10 +19,9 @@
</head>
<body class="antialiased bg-nexi-primary dark:bg-nexi-primary-dark font-sans text-nexi-black transition-colors duration-300">
<div class="min-h-screen flex flex-col sm:justify-center items-center pt-6 sm:pt-0 ">
{{-- TODO: REPLACE WITH OUR LOGO --}}
<div class="mt-24">
<img class="h-24 w-auto rounded" src="https://benjamyn.love/PriceyBot.png" alt="">
</div>
<a href="{{ route('home') }}" class="mt-24" wire:navigate>
<img class="h-24 w-auto rounded" src="{{ asset('images/PriceyBot.webp') }}" alt="all hail pricey bot">
</a>
@if (Route::has('login'))
<livewire:guest.navigation />

View File

@ -43,7 +43,6 @@ new class extends Component
id="user-menu-button"
aria-expanded="false"
aria-haspopup="true">
{{-- TODO: Add User Image URL here --}}
<img class="h-8 w-8 rounded-full bg-gray-50" src="{{ auth()->user()->profile }}" alt="">
<span class="hidden lg:flex lg:items-center">
<span class="ml-4 text-base font-semibold leading-6 text-nexi-black dark:text-nexi-grey" aria-hidden="true"
@ -73,7 +72,7 @@ new class extends Component
x-transition:leave-end="transform opacity-0 scale-95"
>
<div class="mt-3 space-y-1 text-sm">
<x-responsive-nav-link u :href="route('profile')" wire:navigate>
<x-responsive-nav-link :href="route('profile')" wire:navigate>
{{ __('Profile') }}
</x-responsive-nav-link>

View File

@ -20,9 +20,12 @@ Route::middleware(['header.auth', 'throttle:api'])->group(function () {
Route::get('/test', [WebHookController::class, 'test']);
Route::post('/sendQuote', [WebHookController::class, 'sendQuote']);
Route::post('/randomQuote', [WebHookController::class, 'sendRandomQuote']);
Route::post('/user/register', [UserController::class, 'registerUser']);
Route::get('/user/{user:uuid}', [UserController::class, 'getUser'])
->missing(function (Request $request) {
return response()->json(["status" => false, "message" => "User not found"]);
Route::prefix('user')->group(function () {
Route::post('register', [UserController::class, 'registerUser']);
Route::get('{user:uuid}', [UserController::class, 'getUser'])
->missing(function () {
return response()->json(['status' => false, 'message' => 'User not found']);
});
});
});

View File

@ -17,17 +17,18 @@ use Livewire\Volt\Volt;
Route::view('/', 'home')
->name('home');
Route::view('dashboard', 'dashboard')
->middleware(['auth'])
Route::middleware(['auth'])->group(function() {
Route::view('dashboard', 'dashboard')
->name('dashboard');
Route::view('profile', 'profile')
->middleware(['auth'])
Route::view('profile', 'profile')
->name('profile');
Route::view('send', 'admin.send')
->middleware(['auth'])
Route::middleware('auth.admin')->prefix('admin')->group(function () {
Route::view('send', 'admin.send')
->name('admin.send');
});
});
Route::middleware('guest')->group(function () {
Volt::route('login', 'pages.auth.login')