From eb4dd8ec25752b1ba7cb75806d2d9da546cf1b31 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Thu, 18 Apr 2024 17:36:04 -0400 Subject: [PATCH] Adding more content to dd auth --- README.md | 2 +- composer.json | 3 +- config/devdojo/{ => auth}/auth.php | 0 .../components/devdojoauth/input.blade.php | 24 ------- .../components/devdojoauth/logo.blade.php | 3 - .../button.blade.php | 12 ++-- .../checkbox.blade.php | 0 .../container.blade.php | 0 .../heading.blade.php | 6 +- .../views/components/elements/input.blade.php | 24 +++++++ .../{devdojoauth => elements}/link.blade.php | 0 .../views/components/elements/logo.blade.php | 6 ++ .../text-link.blade.php | 4 +- .../views/components/layouts/app.blade.php | 7 +- .../views/components/layouts/setup.blade.php | 44 ++++++++++++ .../setup/sidebar-link-item.blade.php | 11 +++ .../components/setup/sidebar-links.blade.php | 54 ++++++++++++++ resources/views/pages/auth/login.blade.php | 38 +++++----- .../pages/auth/password/[token].blade.php | 29 ++++---- .../pages/auth/password/confirm.blade.php | 42 ++++------- .../views/pages/auth/password/reset.blade.php | 62 ++++++++-------- resources/views/pages/auth/register.blade.php | 40 +++++------ .../views/pages/auth/setup/index.blade.php | 38 ++++++++++ resources/views/pages/auth/verify.blade.php | 70 ++++++++----------- routes/web.php | 4 ++ src/AuthServiceProvider.php | 2 +- .../Controllers/VerifyEmailController.php | 27 +++++++ 27 files changed, 351 insertions(+), 201 deletions(-) rename config/devdojo/{ => auth}/auth.php (100%) delete mode 100644 resources/views/components/devdojoauth/input.blade.php delete mode 100644 resources/views/components/devdojoauth/logo.blade.php rename resources/views/components/{devdojoauth => elements}/button.blade.php (68%) rename resources/views/components/{devdojoauth => elements}/checkbox.blade.php (100%) rename resources/views/components/{devdojoauth => elements}/container.blade.php (100%) rename resources/views/components/{devdojoauth => elements}/heading.blade.php (65%) create mode 100644 resources/views/components/elements/input.blade.php rename resources/views/components/{devdojoauth => elements}/link.blade.php (100%) create mode 100644 resources/views/components/elements/logo.blade.php rename resources/views/components/{devdojoauth => elements}/text-link.blade.php (77%) create mode 100644 resources/views/components/layouts/setup.blade.php create mode 100644 resources/views/components/setup/sidebar-link-item.blade.php create mode 100644 resources/views/components/setup/sidebar-links.blade.php create mode 100644 resources/views/pages/auth/setup/index.blade.php create mode 100644 src/Http/Controllers/VerifyEmailController.php diff --git a/README.md b/README.md index 28302fb..b7dc291 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

Auth Logo

+

Auth Logo


Build Status diff --git a/composer.json b/composer.json index 7f4ee86..808aedb 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "illuminate/support": "^8.0|^9.0|^10.0|^11.0", "laravel/folio": "^1.0", "livewire/livewire": "^3.0", - "livewire/volt": "^1.0" + "livewire/volt": "^1.0", + "codeat3/blade-phosphor-icons": "^2.0" }, "require-dev": { "orchestra/testbench": "^6.0", diff --git a/config/devdojo/auth.php b/config/devdojo/auth/auth.php similarity index 100% rename from config/devdojo/auth.php rename to config/devdojo/auth/auth.php diff --git a/resources/views/components/devdojoauth/input.blade.php b/resources/views/components/devdojoauth/input.blade.php deleted file mode 100644 index f5bf43e..0000000 --- a/resources/views/components/devdojoauth/input.blade.php +++ /dev/null @@ -1,24 +0,0 @@ -@props([ - 'label' => null, - 'id' => null, - 'name' => null, - 'type' => 'text', -]) - -@php $wireModel = $attributes->get('wire:model'); @endphp - -

- @if($label) - - @endif - -
- whereStartsWith('wire:model') }} id="{{ $id ?? '' }}" name="{{ $name ?? '' }}" type="{{ $type ?? '' }}" required autofocus class="appearance-none flex w-full h-10 px-3 py-2 text-sm bg-white dark:text-gray-300 dark:bg-white/[4%] border rounded-md border-gray-300 dark:border-white/10 ring-offset-background placeholder:text-gray-500 dark:placeholder:text-gray-400 focus:border-zinc-800 dark:focus:border-gray-700 focus:outline-none focus:ring-1 focus:ring-zinc-800 dark:focus:ring-white/20 disabled:cursor-not-allowed disabled:opacity-50 @error($wireModel) border-red-300 text-red-900 placeholder-red-300 focus:border-red-300 focus:ring-red @enderror" /> -
- - @error($wireModel) -

{{ $message }}

- @enderror -
\ No newline at end of file diff --git a/resources/views/components/devdojoauth/logo.blade.php b/resources/views/components/devdojoauth/logo.blade.php deleted file mode 100644 index c5b4da2..0000000 --- a/resources/views/components/devdojoauth/logo.blade.php +++ /dev/null @@ -1,3 +0,0 @@ - -{{-- --}} -{{-- --}} \ No newline at end of file diff --git a/resources/views/components/devdojoauth/button.blade.php b/resources/views/components/elements/button.blade.php similarity index 68% rename from resources/views/components/devdojoauth/button.blade.php rename to resources/views/components/elements/button.blade.php index 273c4d1..7300b41 100644 --- a/resources/views/components/devdojoauth/button.blade.php +++ b/resources/views/components/elements/button.blade.php @@ -19,12 +19,12 @@ @php $typeClasses = match ($type) { - 'primary' => 'bg-gray-800 dark:bg-gray-100 text-white dark:text-gray-700 hover:bg-gray-900 dark:focus:ring-offset-gray-900 dark:focus:ring-gray-100 dark:hover:bg-white dark:hover:text-gray-800 focus:ring-2 focus:ring-gray-900 focus:ring-offset-2', - 'secondary' => 'bg-white border text-gray-500 hover:text-gray-700 border-gray-200/70 dark:focus:ring-offset-gray-900 dark:border-gray-400/10 hover:bg-gray-50 active:bg-white dark:focus:ring-gray-700 focus:bg-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-200/60 dark:bg-gray-800/50 dark:hover:bg-gray-800/70 dark:text-gray-400 focus:shadow-outline', - 'success' => 'bg-green-600 text-white hover:bg-green-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-green-700/90 focus:ring-green-700', - 'info' => 'bg-blue-600 text-white hover:bg-blue-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-blue-700/90 focus:ring-blue-700', - 'warning' => 'bg-amber-500 text-white hover:bg-amber-500/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-amber-600/90 focus:ring-amber-600', - 'danger' => 'bg-red-600 text-white hover:bg-red-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-red-700/90 focus:ring-red-700', + 'primary' => 'bg-zinc-900 dark:bg-zinc-100 text-white dark:text-zinc-700 hover:bg-zinc-950 dark:focus:ring-offset-zinc-900 dark:focus:ring-zinc-100 dark:hover:bg-white dark:hover:text-zinc-800 focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2', + 'secondary' => 'bg-white border text-zinc-500 hover:text-zinc-700 border-zinc-200/70 dark:focus:ring-offset-zinc-900 dark:border-zinc-400/10 hover:bg-zinc-50 active:bg-white dark:focus:ring-zinc-700 focus:bg-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-zinc-200/60 dark:bg-zinc-800/50 dark:hover:bg-zinc-800/70 dark:text-zinc-400 focus:shadow-outline', + 'success' => 'bg-green-600 text-white hover:bg-green-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-zinc-900 focus:bg-green-700/90 focus:ring-green-700', + 'info' => 'bg-blue-600 text-white hover:bg-blue-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-zinc-900 focus:bg-blue-700/90 focus:ring-blue-700', + 'warning' => 'bg-amber-500 text-white hover:bg-amber-500/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-zinc-900 focus:bg-amber-600/90 focus:ring-amber-600', + 'danger' => 'bg-red-600 text-white hover:bg-red-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-zinc-900 focus:bg-red-700/90 focus:ring-red-700', }; @endphp diff --git a/resources/views/components/devdojoauth/checkbox.blade.php b/resources/views/components/elements/checkbox.blade.php similarity index 100% rename from resources/views/components/devdojoauth/checkbox.blade.php rename to resources/views/components/elements/checkbox.blade.php diff --git a/resources/views/components/devdojoauth/container.blade.php b/resources/views/components/elements/container.blade.php similarity index 100% rename from resources/views/components/devdojoauth/container.blade.php rename to resources/views/components/elements/container.blade.php diff --git a/resources/views/components/devdojoauth/heading.blade.php b/resources/views/components/elements/heading.blade.php similarity index 65% rename from resources/views/components/devdojoauth/heading.blade.php rename to resources/views/components/elements/heading.blade.php index 7278f2a..74b2417 100644 --- a/resources/views/components/devdojoauth/heading.blade.php +++ b/resources/views/components/elements/heading.blade.php @@ -1,7 +1,7 @@
- - - + + +

{{ $text ?? '' }}

@if($description ?? false)

{{ $description ?? '' }}

diff --git a/resources/views/components/elements/input.blade.php b/resources/views/components/elements/input.blade.php new file mode 100644 index 0000000..b084d80 --- /dev/null +++ b/resources/views/components/elements/input.blade.php @@ -0,0 +1,24 @@ +@props([ + 'label' => null, + 'id' => null, + 'name' => null, + 'type' => 'text', +]) + +@php $wireModel = $attributes->get('wire:model'); @endphp + +
+ @if($label) + + @endif + +
+ whereStartsWith('wire:model') }} id="{{ $id ?? '' }}" name="{{ $name ?? '' }}" type="{{ $type ?? '' }}" required autofocus class="appearance-none flex w-full h-10 px-3 py-2 text-sm bg-white dark:text-gray-300 dark:bg-white/[4%] border rounded-md border-gray-300 dark:border-white/10 ring-offset-background placeholder:text-gray-500 dark:placeholder:text-gray-400 focus:border-zinc-800 dark:focus:border-gray-700 focus:outline-none focus:ring-1 focus:ring-zinc-800 dark:focus:ring-white/20 disabled:cursor-not-allowed disabled:opacity-50 @error($wireModel) border-red-300 text-red-900 placeholder-red-300 focus:border-red-300 focus:ring-red @enderror" /> +
+ + @error($wireModel) +

{{ $message }}

+ @enderror +
\ No newline at end of file diff --git a/resources/views/components/devdojoauth/link.blade.php b/resources/views/components/elements/link.blade.php similarity index 100% rename from resources/views/components/devdojoauth/link.blade.php rename to resources/views/components/elements/link.blade.php diff --git a/resources/views/components/elements/logo.blade.php b/resources/views/components/elements/logo.blade.php new file mode 100644 index 0000000..ee1e4a7 --- /dev/null +++ b/resources/views/components/elements/logo.blade.php @@ -0,0 +1,6 @@ + +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} \ No newline at end of file diff --git a/resources/views/components/devdojoauth/text-link.blade.php b/resources/views/components/elements/text-link.blade.php similarity index 77% rename from resources/views/components/devdojoauth/text-link.blade.php rename to resources/views/components/elements/text-link.blade.php index 071160f..1710d6c 100644 --- a/resources/views/components/devdojoauth/text-link.blade.php +++ b/resources/views/components/elements/text-link.blade.php @@ -1,5 +1,5 @@ -except('wire:navigate') }} class="text-gray-500 underline cursor-pointer dark:text-gray-400 dark:hover:text-gray-300 hover:text-gray-800"> {{ $slot }} - \ No newline at end of file + \ No newline at end of file diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php index d6f8064..24a6e2a 100644 --- a/resources/views/components/layouts/app.blade.php +++ b/resources/views/components/layouts/app.blade.php @@ -6,7 +6,7 @@ {{ config('app.name', 'Laravel') }} - @if(config('devdojo.auth.dev')) + @if(config('devdojo.auth.auth.dev')) @vite(['packages/devdojo/auth/resources/css/auth.css', 'packages/devdojo/auth/resources/css/auth.js']) @else @@ -15,7 +15,8 @@ - - {{ $slot }} +
+ {{ $slot }} +
\ No newline at end of file diff --git a/resources/views/components/layouts/setup.blade.php b/resources/views/components/layouts/setup.blade.php new file mode 100644 index 0000000..e0d5bc8 --- /dev/null +++ b/resources/views/components/layouts/setup.blade.php @@ -0,0 +1,44 @@ + + + + + + + + Authentication Setup + @if(config('devdojo.auth.auth.dev')) + @vite(['packages/devdojo/auth/resources/css/auth.css', 'packages/devdojo/auth/resources/css/auth.js']) + @else + + + @endif + + + +
+ + +
+
+ {{ $slot }} +
+
+
+ + + \ No newline at end of file diff --git a/resources/views/components/setup/sidebar-link-item.blade.php b/resources/views/components/setup/sidebar-link-item.blade.php new file mode 100644 index 0000000..2b0b19c --- /dev/null +++ b/resources/views/components/setup/sidebar-link-item.blade.php @@ -0,0 +1,11 @@ +
  • + + {{-- H --}} + + @if($icon ?? false) + + @endif + + {{ $text ?? '' }} + +
  • \ No newline at end of file diff --git a/resources/views/components/setup/sidebar-links.blade.php b/resources/views/components/setup/sidebar-links.blade.php new file mode 100644 index 0000000..c504def --- /dev/null +++ b/resources/views/components/setup/sidebar-links.blade.php @@ -0,0 +1,54 @@ + \ No newline at end of file diff --git a/resources/views/pages/auth/login.blade.php b/resources/views/pages/auth/login.blade.php index 283c3ab..c8bc5a7 100644 --- a/resources/views/pages/auth/login.blade.php +++ b/resources/views/pages/auth/login.blade.php @@ -19,6 +19,12 @@ public $remember = false; + public $authData = []; + + public function mount(){ + $this->authData = config('devdojo.auth.pages.login'); + } + public function authenticate() { $this->validate(); @@ -38,35 +44,33 @@ public function authenticate() ?> - -
    - - - - + @volt('auth.login') +
    + + + - @volt('auth.login') +
    - - + +
    - - Forgot your password? + + Forgot your password?
    - Sign in + Sign in - @endvolt +
    Don't have an account? - Sign up + Sign up
    - - +
    - + @endvolt \ No newline at end of file diff --git a/resources/views/pages/auth/password/[token].blade.php b/resources/views/pages/auth/password/[token].blade.php index 62df745..f694085 100644 --- a/resources/views/pages/auth/password/[token].blade.php +++ b/resources/views/pages/auth/password/[token].blade.php @@ -67,19 +67,18 @@ function ($user, $password) { ?> -
    - - - - - @volt('auth.password.token') -
    - - - - Reset password - - @endvolt -
    -
    + + + + + @volt('auth.password.token') +
    + + + + Reset password + + @endvolt +
    +
    diff --git a/resources/views/pages/auth/password/confirm.blade.php b/resources/views/pages/auth/password/confirm.blade.php index a59710c..bd1db95 100644 --- a/resources/views/pages/auth/password/confirm.blade.php +++ b/resources/views/pages/auth/password/confirm.blade.php @@ -24,33 +24,19 @@ public function confirm() ?> -
    - - - {{--
    - - - - -

    - Confirm your password -

    -

    - Please confirm your password before continuing -

    -
    --}} - - - @volt('auth.password.confirm') -
    - -
    - Forgot your password? -
    - Confirm password - - @endvolt -
    -
    + + + + + @volt('auth.password.confirm') +
    + +
    + Forgot your password? +
    + Confirm password + + @endvolt +
    \ No newline at end of file diff --git a/resources/views/pages/auth/password/reset.blade.php b/resources/views/pages/auth/password/reset.blade.php index d559693..4655a4d 100644 --- a/resources/views/pages/auth/password/reset.blade.php +++ b/resources/views/pages/auth/password/reset.blade.php @@ -34,43 +34,37 @@ public function sendResetPasswordLink() -
    - - - - @volt('auth.password.reset') - - @if ($emailSentMessage) -
    -
    -
    - - - -
    + + + @volt('auth.password.reset') + + @if ($emailSentMessage) +
    +
    +
    + + + +
    -
    -

    - {{ $emailSentMessage }} -

    -
    +
    +

    + {{ $emailSentMessage }} +

    - @else -
    - - Send password reset link - - @endif -
    - Or - return to login
    - - @endvolt - - - -
    + @else +
    + + Send password reset link + + @endif +
    + Or + return to login +
    +
    + @endvolt \ No newline at end of file diff --git a/resources/views/pages/auth/register.blade.php b/resources/views/pages/auth/register.blade.php index c238ceb..0ef4082 100644 --- a/resources/views/pages/auth/register.blade.php +++ b/resources/views/pages/auth/register.blade.php @@ -47,27 +47,23 @@ public function register() -
    - - - - - @volt('auth.register') -
    - - - - - Register - - @endvolt - -
    - Already have an account? - Sign in -
    -
    - -
    + + + + @volt('auth.register') +
    + + + + + Register + + @endvolt + +
    + Already have an account? + Sign in +
    +
    diff --git a/resources/views/pages/auth/setup/index.blade.php b/resources/views/pages/auth/setup/index.blade.php new file mode 100644 index 0000000..6b5ab15 --- /dev/null +++ b/resources/views/pages/auth/setup/index.blade.php @@ -0,0 +1,38 @@ +validate(); + + session()->put('auth.password_confirmed_at', time()); + + return redirect()->intended('/'); + } +}; + +?> + + + +
    + @volt('auth.setup') + + test + + {{-- --}} + @endvolt + +
    + +
    \ No newline at end of file diff --git a/resources/views/pages/auth/verify.blade.php b/resources/views/pages/auth/verify.blade.php index 69dbb43..77ee413 100644 --- a/resources/views/pages/auth/verify.blade.php +++ b/resources/views/pages/auth/verify.blade.php @@ -5,8 +5,8 @@ use function Laravel\Folio\{middleware, name}; use Livewire\Volt\Component; -middleware(['auth', 'throttle:6,1']); -name('auth.verification.notice'); +//middleware(['auth', 'throttle:6,1']); +name('verification.notice'); new class extends Component { @@ -30,49 +30,37 @@ public function resend() -
    - -
    - - - - -

    - Verify your email address -

    - -
    - Or - - -
    -
    + -
    + - @volt('auth.verify') -
    - @if (session('resent')) - - @endvolt - + @endif + +
    +

    Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.

    +
    + @endvolt + + +
    + or + +
    -
    + +
    diff --git a/routes/web.php b/routes/web.php index 36436f4..88bcf36 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ group(function () { Route::post('logout', LogoutController::class) ->name('logout'); + Route::get('verify-email/{id}/{hash}', VerifyEmailController::class) + ->middleware(['signed', 'throttle:6,1']) + ->name('verification.verify'); }); \ No newline at end of file diff --git a/src/AuthServiceProvider.php b/src/AuthServiceProvider.php index 91b4cc7..b72451a 100644 --- a/src/AuthServiceProvider.php +++ b/src/AuthServiceProvider.php @@ -75,7 +75,7 @@ private function registerVoltDirectory(){ public function register() { // Automatically apply the package configuration - $this->mergeConfigFrom(__DIR__.'/../config/devdojo/auth.php', 'devdojo.auth'); + $this->mergeConfigFrom(__DIR__.'/../config/devdojo/auth/auth.php', 'devdojo.auth.auth'); // Register the main class to use with the facade $this->app->singleton('devdojoauth', function () { diff --git a/src/Http/Controllers/VerifyEmailController.php b/src/Http/Controllers/VerifyEmailController.php new file mode 100644 index 0000000..5636e08 --- /dev/null +++ b/src/Http/Controllers/VerifyEmailController.php @@ -0,0 +1,27 @@ +user()->hasVerifiedEmail()) { + return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); + } + + if ($request->user()->markEmailAsVerified()) { + event(new Verified($request->user())); + } + + return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); + } +}