class('font-medium text-sm text-green-600 dark:text-green-400') }} />
3 |
4 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/auth-session-status.blade.php:
--------------------------------------------------------------------------------
1 | @props(['status'])
2 |
3 | @if ($status)
4 |
merge(['class' => 'font-medium text-sm text-green-600 dark:text-green-400']) }}>
5 | {{ $status }}
6 |
7 | @endif
8 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/InputError.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | {{ message }}
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/dropdown-link.blade.php:
--------------------------------------------------------------------------------
1 |
merge(['class' => 'block w-full px-4 py-2 text-left text-sm leading-5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-800 transition duration-150 ease-in-out']) }}>{{ $slot }}
2 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/InputLabel.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 | {{ value }}
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/input-error.blade.php:
--------------------------------------------------------------------------------
1 | @props(['messages'])
2 |
3 | @if ($messages)
4 |
merge(['class' => 'text-sm text-red-600 dark:text-red-400 space-y-1']) }}>
5 | @foreach ((array) $messages as $message)
6 | {{ $message }}
7 | @endforeach
8 |
9 | @endif
10 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/InputLabel.jsx:
--------------------------------------------------------------------------------
1 | export default function InputLabel({ forInput, value, className, children }) {
2 | return (
3 |
4 | {value ? value : children}
5 |
6 | );
7 | }
8 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/components/dropdown-link.blade.php:
--------------------------------------------------------------------------------
1 | @props(['as' => 'Link'])
2 |
3 | <{{ $as }} {{ $attributes->class('block px-4 py-2 text-sm leading-5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-800 transition duration-150 ease-in-out') }}>{{ $slot }}{{ $as }}>
4 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/text-input.blade.php:
--------------------------------------------------------------------------------
1 | @props(['disabled' => false])
2 |
3 |
merge(['class' => 'border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm']) !!}>
4 |
--------------------------------------------------------------------------------
/stubs/inertia-react/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import laravel from 'laravel-vite-plugin';
3 | import react from '@vitejs/plugin-react';
4 |
5 | export default defineConfig({
6 | plugins: [
7 | laravel({
8 | input: 'resources/js/app.jsx',
9 | refresh: true,
10 | }),
11 | react(),
12 | ],
13 | });
14 |
--------------------------------------------------------------------------------
/stubs/default/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import laravel from 'laravel-vite-plugin';
3 |
4 | export default defineConfig({
5 | plugins: [
6 | laravel({
7 | input: [
8 | 'resources/css/app.css',
9 | 'resources/js/app.js',
10 | ],
11 | refresh: true,
12 | }),
13 | ],
14 | });
15 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/auth-card.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ $logo }}
4 |
5 |
6 |
7 | {{ $slot }}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/stubs/api/pest-tests/Feature/Auth/RegistrationTest.php:
--------------------------------------------------------------------------------
1 | post('/register', [
5 | 'name' => 'Test User',
6 | 'email' => 'test@example.com',
7 | 'password' => 'password',
8 | 'password_confirmation' => 'password',
9 | ]);
10 |
11 | $this->assertAuthenticated();
12 | $response->assertNoContent();
13 | });
14 |
--------------------------------------------------------------------------------
/stubs/default/app/View/Components/AppLayout.php:
--------------------------------------------------------------------------------
1 | merge(['type' => 'submit', 'class' => 'inline-flex items-center px-4 py-2 bg-red-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-red-500 active:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150']) }}>
2 | {{ $slot }}
3 |
4 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/DropdownLink.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/layouts/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 | @include('layouts.navigation')
3 |
4 |
5 |
6 |
7 | {{ $header }}
8 |
9 |
10 |
11 |
12 |
13 | {{ $slot }}
14 |
15 |
16 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/Checkbox.jsx:
--------------------------------------------------------------------------------
1 | export default function Checkbox({ name, value, handleChange }) {
2 | return (
3 |
handleChange(e)}
9 | />
10 | );
11 | }
12 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/components/dropdown.blade.php:
--------------------------------------------------------------------------------
1 | @props(['width' => '48'])
2 |
3 | @php
4 | switch ($width) {
5 | case '48':
6 | $width = 'w-48';
7 | break;
8 | }
9 | @endphp
10 |
11 |
except('width') }}>
12 |
13 | {{ $trigger }}
14 |
15 |
16 |
17 | {{ $content }}
18 |
19 |
20 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/secondary-button.blade.php:
--------------------------------------------------------------------------------
1 |
merge(['type' => 'button', 'class' => 'inline-flex items-center px-4 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-500 rounded-md font-semibold text-xs text-gray-700 dark:text-gray-300 uppercase tracking-widest shadow-sm hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 disabled:opacity-25 transition ease-in-out duration-150']) }}>
2 | {{ $slot }}
3 |
4 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import laravel from 'laravel-vite-plugin';
3 | import vue from '@vitejs/plugin-vue';
4 |
5 | export default defineConfig({
6 | plugins: [
7 | laravel({
8 | input: 'resources/js/app.js',
9 | refresh: true,
10 | }),
11 | vue({
12 | template: {
13 | transformAssetUrls: {
14 | base: null,
15 | includeAbsolute: false,
16 | },
17 | },
18 | }),
19 | ],
20 | });
21 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/primary-button.blade.php:
--------------------------------------------------------------------------------
1 |
merge(['type' => 'submit', 'class' => 'inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150']) }}>
2 | {{ $slot }}
3 |
4 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Feature/Auth/RegistrationTest.php:
--------------------------------------------------------------------------------
1 | get('/register');
5 |
6 | $response->assertStatus(200);
7 | });
8 |
9 | test('new users can register', function () {
10 | $response = $this->post('/register', [
11 | 'name' => 'Test User',
12 | 'email' => 'test@example.com',
13 | 'password' => 'password',
14 | 'password_confirmation' => 'password',
15 | ]);
16 |
17 | $this->assertAuthenticated();
18 | $response->assertRedirect('/dashboard');
19 | });
20 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/components/auth-card.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | @isset($logo)
4 | {{ $logo }}
5 | @else
6 |
7 |
8 |
9 | @endisset
10 |
11 |
12 |
13 | {{ $slot }}
14 |
15 |
16 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/dashboard.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Dashboard') }}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | You're logged in!
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/stubs/api/routes/web.php:
--------------------------------------------------------------------------------
1 | app()->version()];
18 | });
19 |
20 | require __DIR__.'/auth.php';
21 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/EmailVerificationPromptController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()
18 | ? redirect()->intended('/dashboard')
19 | : view('auth.verify-email');
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/stubs/default/tailwind.config.js:
--------------------------------------------------------------------------------
1 | import defaultTheme from 'tailwindcss/defaultTheme';
2 | import forms from '@tailwindcss/forms';
3 |
4 | /** @type {import('tailwindcss').Config} */
5 | export default {
6 | content: [
7 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
8 | './storage/framework/views/*.php',
9 | './resources/views/**/*.blade.php',
10 | ],
11 |
12 | theme: {
13 | extend: {
14 | fontFamily: {
15 | sans: ['Nunito', ...defaultTheme.fontFamily.sans],
16 | },
17 | },
18 | },
19 |
20 | plugins: [forms],
21 | };
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/DangerButton.vue:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Requests/ProfileUpdateRequest.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | public function rules()
17 | {
18 | return [
19 | 'name' => ['string', 'max:255'],
20 | 'email' => ['email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)],
21 | ];
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/stubs/api/routes/api.php:
--------------------------------------------------------------------------------
1 | get('/user', function (Request $request) {
18 | return $request->user();
19 | });
20 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/dashboard.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Dashboard') }}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{ __("You're logged in!") }}
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/stubs/inertia-common/tailwind.config.js:
--------------------------------------------------------------------------------
1 | const defaultTheme = require('tailwindcss/defaultTheme');
2 |
3 | /** @type {import('tailwindcss').Config} */
4 | module.exports = {
5 | content: [
6 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
7 | './storage/framework/views/*.php',
8 | './resources/views/**/*.blade.php',
9 | './resources/js/**/*.vue',
10 | ],
11 |
12 | theme: {
13 | extend: {
14 | fontFamily: {
15 | sans: ['Nunito', ...defaultTheme.fontFamily.sans],
16 | },
17 | },
18 | },
19 |
20 | plugins: [require('@tailwindcss/forms')],
21 | };
22 |
--------------------------------------------------------------------------------
/stubs/api/tests/Feature/Auth/RegistrationTest.php:
--------------------------------------------------------------------------------
1 | post('/register', [
15 | 'name' => 'Test User',
16 | 'email' => 'test@example.com',
17 | 'password' => 'password',
18 | 'password_confirmation' => 'password',
19 | ]);
20 |
21 | $this->assertAuthenticated();
22 | $response->assertNoContent();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/EmailVerificationPromptController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()
19 | ? redirect()->intended('/dashboard')
20 | : Inertia::render('Auth/VerifyEmail', ['status' => session('status')]);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/stubs/api/pest-tests/Feature/Auth/AuthenticationTest.php:
--------------------------------------------------------------------------------
1 | create();
7 |
8 | $response = $this->post('/login', [
9 | 'email' => $user->email,
10 | 'password' => 'password',
11 | ]);
12 |
13 | $this->assertAuthenticated();
14 | $response->assertNoContent();
15 | });
16 |
17 | test('users can not authenticate with invalid password', function () {
18 | $user = User::factory()->create();
19 |
20 | $this->post('/login', [
21 | 'email' => $user->email,
22 | 'password' => 'wrong-password',
23 | ]);
24 |
25 | $this->assertGuest();
26 | });
27 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/root.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
{{ config('app.name', 'Laravel') }}
9 |
10 |
11 |
12 |
13 |
14 | @vite(['resources/js/app.js'])
15 | @spladeHead
16 |
17 |
18 | @splade
19 |
20 |
21 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/SecondaryButton.vue:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/auth/confirm-password.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('This is a secure area of the application. Please confirm your password before continuing.') }}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Layouts/GuestLayout.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
13 |
14 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/views/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
{{ config('app.name', 'Laravel') }}
8 |
9 |
10 |
11 |
12 |
13 | @routes
14 | @vite(['resources/js/app.js', "resources/js/Pages/{$page['component']}.vue"])
15 | @inertiaHead
16 |
17 |
18 | @inertia
19 |
20 |
21 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/PrimaryButton.vue:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/EmailVerificationNotificationController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()) {
18 | return redirect()->intended('/dashboard');
19 | }
20 |
21 | $request->user()->sendEmailVerificationNotification();
22 |
23 | return back()->with('status', 'verification-link-sent');
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/EmailVerificationNotificationController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()) {
18 | return redirect()->intended('/dashboard');
19 | }
20 |
21 | $request->user()->sendEmailVerificationNotification();
22 |
23 | return back()->with('status', 'verification-link-sent');
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/views/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
{{ config('app.name', 'Laravel') }}
8 |
9 |
10 |
11 |
12 |
13 | @routes
14 | @viteReactRefresh
15 | @vite(['resources/js/app.jsx', "resources/js/Pages/{$page['component']}.jsx"])
16 | @inertiaHead
17 |
18 |
19 | @inertia
20 |
21 |
22 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Layouts/GuestLayout.jsx:
--------------------------------------------------------------------------------
1 | import ApplicationLogo from '@/Components/ApplicationLogo';
2 | import { Link } from '@inertiajs/inertia-react';
3 |
4 | export default function Guest({ children }) {
5 | return (
6 |
7 |
12 |
13 |
14 | {children}
15 |
16 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/layouts/guest.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
{{ config('app.name', 'Laravel') }}
9 |
10 |
11 |
12 |
13 |
14 | @vite(['resources/css/app.css', 'resources/js/app.js'])
15 |
16 |
17 |
18 | {{ $slot }}
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Breeze for Laravel Splade
2 |
3 | 💡 This is a fork of the [Laravel Breeze starter kit](https://laravel.com/docs/10.x/starter-kits#laravel-breeze) with a [Laravel Splade](https://github.com/protonemedia/laravel-splade) implementation.
4 |
5 | ## Documentation
6 |
7 | 📖 You can find the documentation at [Splade.dev](https://splade.dev/docs/breeze) (and [here](https://github.com/protonemedia/laravel-splade-docs) its source code).
8 |
9 | ## Changelog
10 |
11 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
12 |
13 | ## Security
14 |
15 | If you discover any security related issues, please email pascal@protone.media instead of using the issue tracker.
16 |
17 | ## License
18 |
19 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
20 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Controllers/Auth/EmailVerificationNotificationController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()) {
18 | return redirect()->intended('/dashboard');
19 | }
20 |
21 | $request->user()->sendEmailVerificationNotification();
22 |
23 | return response()->json(['status' => 'verification-link-sent']);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/app.jsx:
--------------------------------------------------------------------------------
1 | import './bootstrap';
2 | import '../css/app.css';
3 |
4 | import { createRoot } from 'react-dom/client';
5 | import { createInertiaApp } from '@inertiajs/inertia-react';
6 | import { InertiaProgress } from '@inertiajs/progress';
7 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
8 |
9 | const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
10 |
11 | createInertiaApp({
12 | title: (title) => `${title} - ${appName}`,
13 | resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')),
14 | setup({ el, App, props }) {
15 | const root = createRoot(el);
16 |
17 | root.render(
);
18 | },
19 | });
20 |
21 | InertiaProgress.init({ color: '#4B5563' });
22 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/TextInput.vue:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
26 |
27 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/DangerButton.jsx:
--------------------------------------------------------------------------------
1 | export default function DangerButton({ type = 'submit', className = '', processing, children, onClick }) {
2 | return (
3 |
13 | {children}
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/auth/reset-password.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/nav-link.blade.php:
--------------------------------------------------------------------------------
1 | @props(['active'])
2 |
3 | @php
4 | $classes = ($active ?? false)
5 | ? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 dark:border-indigo-600 text-sm font-medium leading-5 text-gray-900 dark:text-gray-100 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
6 | : 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300 dark:hover:border-gray-700 focus:outline-none focus:text-gray-700 dark:focus:text-gray-300 focus:border-gray-300 dark:focus:border-gray-700 transition duration-150 ease-in-out';
7 | @endphp
8 |
9 |
merge(['class' => $classes]) }}>
10 | {{ $slot }}
11 |
12 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Pages/Dashboard.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Dashboard
12 |
13 |
14 |
15 |
16 |
17 |
You're logged in!
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/components/nav-link.blade.php:
--------------------------------------------------------------------------------
1 | @props(['active', 'as' => 'Link'])
2 |
3 | @php
4 | $classes = ($active ?? false)
5 | ? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 dark:border-indigo-600 text-sm font-medium leading-5 text-gray-900 dark:text-gray-100 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
6 | : 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300 dark:hover:border-gray-700 focus:outline-none focus:text-gray-700 dark:focus:text-gray-300 focus:border-gray-300 dark:focus:border-gray-700 transition duration-150 ease-in-out';
7 | @endphp
8 |
9 | <{{ $as }} {{ $attributes->class($classes) }}>
10 | {{ $slot }}
11 | {{ $as }}>
12 |
--------------------------------------------------------------------------------
/stubs/default/tests/Feature/Auth/RegistrationTest.php:
--------------------------------------------------------------------------------
1 | get('/register');
15 |
16 | $response->assertStatus(200);
17 | }
18 |
19 | public function test_new_users_can_register()
20 | {
21 | $response = $this->post('/register', [
22 | 'name' => 'Test User',
23 | 'email' => 'test@example.com',
24 | 'password' => 'password',
25 | 'password_confirmation' => 'password',
26 | ]);
27 |
28 | $this->assertAuthenticated();
29 | $response->assertRedirect('/dashboard');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Middleware/EnsureEmailIsVerified.php:
--------------------------------------------------------------------------------
1 | user() ||
20 | ($request->user() instanceof MustVerifyEmail &&
21 | ! $request->user()->hasVerifiedEmail())) {
22 | return response()->json(['message' => 'Your email address is not verified.'], 409);
23 | }
24 |
25 | return $next($request);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Feature/Auth/AuthenticationTest.php:
--------------------------------------------------------------------------------
1 | get('/login');
7 |
8 | $response->assertStatus(200);
9 | });
10 |
11 | test('users can authenticate using the login screen', function () {
12 | $user = User::factory()->create();
13 |
14 | $response = $this->post('/login', [
15 | 'email' => $user->email,
16 | 'password' => 'password',
17 | ]);
18 |
19 | $this->assertAuthenticated();
20 | $response->assertRedirect('/dashboard');
21 | });
22 |
23 | test('users can not authenticate with invalid password', function () {
24 | $user = User::factory()->create();
25 |
26 | $this->post('/login', [
27 | 'email' => $user->email,
28 | 'password' => 'wrong-password',
29 | ]);
30 |
31 | $this->assertGuest();
32 | });
33 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/Checkbox.vue:
--------------------------------------------------------------------------------
1 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/VerifyEmailController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()) {
19 | return redirect()->intended('/dashboard?verified=1');
20 | }
21 |
22 | if ($request->user()->markEmailAsVerified()) {
23 | event(new Verified($request->user()));
24 | }
25 |
26 | return redirect()->intended('/dashboard?verified=1');
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/PasswordController.php:
--------------------------------------------------------------------------------
1 | validate([
20 | 'current_password' => ['required', 'current_password'],
21 | 'password' => ['required', Password::defaults(), 'confirmed'],
22 | ]);
23 |
24 | $request->user()->update([
25 | 'password' => Hash::make($validated['password']),
26 | ]);
27 |
28 | return back();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/auth/forgot-password.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/VerifyEmailController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()) {
19 | return redirect()->intended('/dashboard?verified=1');
20 | }
21 |
22 | if ($request->user()->markEmailAsVerified()) {
23 | event(new Verified($request->user()));
24 | }
25 |
26 | return redirect()->intended('/dashboard?verified=1');
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/SecondaryButton.jsx:
--------------------------------------------------------------------------------
1 | export default function SecondaryButton({ type = 'button', className = '', processing, children, onClick }) {
2 | return (
3 |
13 | {children}
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/app.js:
--------------------------------------------------------------------------------
1 | import './bootstrap';
2 | import '../css/app.css';
3 |
4 | import { createApp, h } from 'vue';
5 | import { createInertiaApp } from '@inertiajs/inertia-vue3';
6 | import { InertiaProgress } from '@inertiajs/progress';
7 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
8 | import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
9 |
10 | const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
11 |
12 | createInertiaApp({
13 | title: (title) => `${title} - ${appName}`,
14 | resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
15 | setup({ el, app, props, plugin }) {
16 | return createApp({ render: () => h(app, props) })
17 | .use(plugin)
18 | .use(ZiggyVue, Ziggy)
19 | .mount(el);
20 | },
21 | });
22 |
23 | InertiaProgress.init({ color: '#4B5563' });
24 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/PasswordController.php:
--------------------------------------------------------------------------------
1 | validateWithBag('updatePassword', [
20 | 'current_password' => ['required', 'current_password'],
21 | 'password' => ['required', Password::defaults(), 'confirmed'],
22 | ]);
23 |
24 | $request->user()->update([
25 | 'password' => Hash::make($validated['password']),
26 | ]);
27 |
28 | return back()->with('status', 'password-updated');
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/PrimaryButton.jsx:
--------------------------------------------------------------------------------
1 | export default function PrimaryButton({ type = 'submit', className = '', processing, children, onClick }) {
2 | return (
3 |
13 | {children}
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Feature/Auth/PasswordConfirmationTest.php:
--------------------------------------------------------------------------------
1 | create();
7 |
8 | $response = $this->actingAs($user)->get('/confirm-password');
9 |
10 | $response->assertStatus(200);
11 | });
12 |
13 | test('password can be confirmed', function () {
14 | $user = User::factory()->create();
15 |
16 | $response = $this->actingAs($user)->post('/confirm-password', [
17 | 'password' => 'password',
18 | ]);
19 |
20 | $response->assertRedirect();
21 | $response->assertSessionHasNoErrors();
22 | });
23 |
24 | test('password is not confirmed with invalid password', function () {
25 | $user = User::factory()->create();
26 |
27 | $response = $this->actingAs($user)->post('/confirm-password', [
28 | 'password' => 'wrong-password',
29 | ]);
30 |
31 | $response->assertSessionHasErrors();
32 | });
33 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Pages/Dashboard.jsx:
--------------------------------------------------------------------------------
1 | import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
2 | import { Head } from '@inertiajs/inertia-react';
3 |
4 | export default function Dashboard(props) {
5 | return (
6 |
Dashboard}
10 | >
11 |
12 |
13 |
14 |
15 |
16 |
You're logged in!
17 |
18 |
19 |
20 |
21 | );
22 | }
23 |
--------------------------------------------------------------------------------
/stubs/api/app/Providers/AuthServiceProvider.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
17 | ];
18 |
19 | /**
20 | * Register any authentication / authorization services.
21 | *
22 | * @return void
23 | */
24 | public function boot()
25 | {
26 | $this->registerPolicies();
27 |
28 | ResetPassword::createUrlUsing(function ($notifiable, $token) {
29 | return config('app.frontend_url')."/password-reset/$token?email={$notifiable->getEmailForPasswordReset()}";
30 | });
31 |
32 | //
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/stubs/api/config/cors.php:
--------------------------------------------------------------------------------
1 | ['*'],
19 |
20 | 'allowed_methods' => ['*'],
21 |
22 | 'allowed_origins' => [env('FRONTEND_URL', 'http://localhost:3000')],
23 |
24 | 'allowed_origins_patterns' => [],
25 |
26 | 'allowed_headers' => ['*'],
27 |
28 | 'exposed_headers' => [],
29 |
30 | 'max_age' => 0,
31 |
32 | 'supports_credentials' => true,
33 |
34 | ];
35 |
--------------------------------------------------------------------------------
/stubs/api/tests/Feature/Auth/AuthenticationTest.php:
--------------------------------------------------------------------------------
1 | create();
16 |
17 | $response = $this->post('/login', [
18 | 'email' => $user->email,
19 | 'password' => 'password',
20 | ]);
21 |
22 | $this->assertAuthenticated();
23 | $response->assertNoContent();
24 | }
25 |
26 | public function test_users_can_not_authenticate_with_invalid_password()
27 | {
28 | $user = User::factory()->create();
29 |
30 | $this->post('/login', [
31 | 'email' => $user->email,
32 | 'password' => 'wrong-password',
33 | ]);
34 |
35 | $this->assertGuest();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/NavLink.jsx:
--------------------------------------------------------------------------------
1 | import { Link } from '@inertiajs/inertia-react';
2 |
3 | export default function NavLink({ href, active, children }) {
4 | return (
5 |
13 | {children}
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/NavLink.vue:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Controllers/Auth/VerifyEmailController.php:
--------------------------------------------------------------------------------
1 | user()->hasVerifiedEmail()) {
19 | return redirect()->intended(
20 | config('app.frontend_url').'/dashboard?verified=1'
21 | );
22 | }
23 |
24 | if ($request->user()->markEmailAsVerified()) {
25 | event(new Verified($request->user()));
26 | }
27 |
28 | return redirect()->intended(
29 | config('app.frontend_url').'/dashboard?verified=1'
30 | );
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/BreezeServiceProvider.php:
--------------------------------------------------------------------------------
1 | app->runningInConsole()) {
28 | return;
29 | }
30 |
31 | $this->commands([
32 | Console\InstallCommand::class,
33 | ]);
34 | }
35 |
36 | /**
37 | * Get the services provided by the provider.
38 | *
39 | * @return array
40 | */
41 | public function provides()
42 | {
43 | return [Console\InstallCommand::class];
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/ssr.jsx:
--------------------------------------------------------------------------------
1 | import ReactDOMServer from 'react-dom/server';
2 | import { createInertiaApp } from '@inertiajs/inertia-react';
3 | import createServer from '@inertiajs/server';
4 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
5 | import route from '../../vendor/tightenco/ziggy/dist/index.m';
6 |
7 | const appName = 'Laravel';
8 |
9 | createServer((page) =>
10 | createInertiaApp({
11 | page,
12 | render: ReactDOMServer.renderToString,
13 | title: (title) => `${title} - ${appName}`,
14 | resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')),
15 | setup: ({ App, props }) => {
16 | global.route = (name, params, absolute) =>
17 | route(name, params, absolute, {
18 | ...page.props.ziggy,
19 | location: new URL(page.props.ziggy.location),
20 | });
21 |
22 | return
;
23 | },
24 | })
25 | );
26 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/ssr.js:
--------------------------------------------------------------------------------
1 | import { createSSRApp, h } from 'vue';
2 | import { renderToString } from '@vue/server-renderer';
3 | import { createInertiaApp } from '@inertiajs/inertia-vue3';
4 | import createServer from '@inertiajs/server';
5 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
6 | import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
7 |
8 | const appName = 'Laravel';
9 |
10 | createServer((page) =>
11 | createInertiaApp({
12 | page,
13 | render: renderToString,
14 | title: (title) => `${title} - ${appName}`,
15 | resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
16 | setup({ app, props, plugin }) {
17 | return createSSRApp({ render: () => h(app, props) })
18 | .use(plugin)
19 | .use(ZiggyVue, {
20 | ...page.props.ziggy,
21 | location: new URL(page.props.ziggy.location),
22 | });
23 | },
24 | })
25 | );
26 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/components/responsive-nav-link.blade.php:
--------------------------------------------------------------------------------
1 | @props(['active', 'as' => 'Link'])
2 |
3 | @php
4 | $classes = ($active ?? false)
5 | ? 'block pl-3 pr-4 py-2 border-l-4 border-indigo-400 dark:border-indigo-600 text-base font-medium text-indigo-700 dark:text-indigo-300 bg-indigo-50 dark:bg-indigo-900/50 focus:outline-none focus:text-indigo-800 dark:focus:text-indigo-200 focus:bg-indigo-100 dark:focus:bg-indigo-900 focus:border-indigo-700 dark:focus:border-indigo-300 transition duration-150 ease-in-out'
6 | : 'block pl-3 pr-4 py-2 border-l-4 border-transparent text-base font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600 focus:outline-none focus:text-gray-800 dark:focus:text-gray-200 focus:bg-gray-50 dark:focus:bg-gray-700 focus:border-gray-300 dark:focus:border-gray-600 transition duration-150 ease-in-out';
7 | @endphp
8 |
9 | <{{ $as }} {{ $attributes->class($classes) }}>
10 | {{ $slot }}
11 | {{ $as }}>
12 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/bootstrap.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | window._ = _;
3 |
4 | /**
5 | * We'll load the axios HTTP library which allows us to easily issue requests
6 | * to our Laravel back-end. This library automatically handles sending the
7 | * CSRF token as a header based on the value of the "XSRF" token cookie.
8 | */
9 |
10 | import axios from 'axios';
11 | window.axios = axios;
12 |
13 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
14 |
15 | /**
16 | * Echo exposes an expressive API for subscribing to channels and listening
17 | * for events that are broadcast by Laravel. Echo and event broadcasting
18 | * allows your team to easily build robust real-time web applications.
19 | */
20 |
21 | // import Echo from 'laravel-echo';
22 |
23 | // import Pusher from 'pusher-js';
24 | // window.Pusher = Pusher;
25 |
26 | // window.Echo = new Echo({
27 | // broadcaster: 'pusher',
28 | // key: import.meta.env.VITE_PUSHER_APP_KEY,
29 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER,
30 | // forceTLS: true
31 | // });
32 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/responsive-nav-link.blade.php:
--------------------------------------------------------------------------------
1 | @props(['active'])
2 |
3 | @php
4 | $classes = ($active ?? false)
5 | ? 'block w-full pl-3 pr-4 py-2 border-l-4 border-indigo-400 dark:border-indigo-600 text-left text-base font-medium text-indigo-700 dark:text-indigo-300 bg-indigo-50 dark:bg-indigo-900/50 focus:outline-none focus:text-indigo-800 dark:focus:text-indigo-200 focus:bg-indigo-100 dark:focus:bg-indigo-900 focus:border-indigo-700 dark:focus:border-indigo-300 transition duration-150 ease-in-out'
6 | : 'block w-full pl-3 pr-4 py-2 border-l-4 border-transparent text-left text-base font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600 focus:outline-none focus:text-gray-800 dark:focus:text-gray-200 focus:bg-gray-50 dark:focus:bg-gray-700 focus:border-gray-300 dark:focus:border-gray-600 transition duration-150 ease-in-out';
7 | @endphp
8 |
9 |
merge(['class' => $classes]) }}>
10 | {{ $slot }}
11 |
12 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/bootstrap.js:
--------------------------------------------------------------------------------
1 | import _ from 'lodash';
2 | window._ = _;
3 |
4 | /**
5 | * We'll load the axios HTTP library which allows us to easily issue requests
6 | * to our Laravel back-end. This library automatically handles sending the
7 | * CSRF token as a header based on the value of the "XSRF" token cookie.
8 | */
9 |
10 | import axios from 'axios';
11 | window.axios = axios;
12 |
13 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
14 |
15 | /**
16 | * Echo exposes an expressive API for subscribing to channels and listening
17 | * for events that are broadcast by Laravel. Echo and event broadcasting
18 | * allows your team to easily build robust real-time web applications.
19 | */
20 |
21 | // import Echo from 'laravel-echo';
22 |
23 | // import Pusher from 'pusher-js';
24 | // window.Pusher = Pusher;
25 |
26 | // window.Echo = new Echo({
27 | // broadcaster: 'pusher',
28 | // key: import.meta.env.VITE_PUSHER_APP_KEY,
29 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER,
30 | // forceTLS: true
31 | // });
32 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Controllers/Auth/AuthenticatedSessionController.php:
--------------------------------------------------------------------------------
1 | authenticate();
20 |
21 | $request->session()->regenerate();
22 |
23 | return response()->noContent();
24 | }
25 |
26 | /**
27 | * Destroy an authenticated session.
28 | *
29 | * @return \Illuminate\Http\Response
30 | */
31 | public function destroy(Request $request)
32 | {
33 | Auth::guard('web')->logout();
34 |
35 | $request->session()->invalidate();
36 |
37 | $request->session()->regenerateToken();
38 |
39 | return response()->noContent();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/auth/register.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{ __('Already registered?') }}
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Taylor Otwell
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/profile/partials/delete-user-form.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Delete Account') }}
5 |
6 |
7 |
8 | {{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.') }}
9 |
10 |
11 |
12 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/stubs/default/routes/web.php:
--------------------------------------------------------------------------------
1 | middleware(['auth', 'verified'])->name('dashboard');
24 |
25 | Route::middleware('auth')->group(function () {
26 | Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
27 | Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
28 | Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
29 | });
30 |
31 | require __DIR__.'/auth.php';
32 |
--------------------------------------------------------------------------------
/stubs/api/pest-tests/Feature/Auth/PasswordResetTest.php:
--------------------------------------------------------------------------------
1 | create();
11 |
12 | $this->post('/forgot-password', ['email' => $user->email]);
13 |
14 | Notification::assertSentTo($user, ResetPassword::class);
15 | });
16 |
17 | test('password can be reset with valid token', function () {
18 | Notification::fake();
19 |
20 | $user = User::factory()->create();
21 |
22 | $this->post('/forgot-password', ['email' => $user->email]);
23 |
24 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
25 | $response = $this->post('/reset-password', [
26 | 'token' => $notification->token,
27 | 'email' => $user->email,
28 | 'password' => 'password',
29 | 'password_confirmation' => 'password',
30 | ]);
31 |
32 | $response->assertSessionHasNoErrors();
33 |
34 | return true;
35 | });
36 | });
37 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/profile/edit.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Profile') }}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | @include('profile.partials.update-profile-information-form')
13 |
14 |
15 |
16 |
17 |
18 | @include('profile.partials.update-password-form')
19 |
20 |
21 |
22 |
23 |
24 | @include('profile.partials.delete-user-form')
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/stubs/default/tests/Feature/Auth/AuthenticationTest.php:
--------------------------------------------------------------------------------
1 | get('/login');
16 |
17 | $response->assertStatus(200);
18 | }
19 |
20 | public function test_users_can_authenticate_using_the_login_screen()
21 | {
22 | $user = User::factory()->create();
23 |
24 | $response = $this->post('/login', [
25 | 'email' => $user->email,
26 | 'password' => 'password',
27 | ]);
28 |
29 | $this->assertAuthenticated();
30 | $response->assertRedirect('/dashboard');
31 | }
32 |
33 | public function test_users_can_not_authenticate_with_invalid_password()
34 | {
35 | $user = User::factory()->create();
36 |
37 | $this->post('/login', [
38 | 'email' => $user->email,
39 | 'password' => 'wrong-password',
40 | ]);
41 |
42 | $this->assertGuest();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/ConfirmablePasswordController.php:
--------------------------------------------------------------------------------
1 | validate([
30 | 'email' => $request->user()->email,
31 | 'password' => $request->password,
32 | ])) {
33 | throw ValidationException::withMessages([
34 | 'password' => __('auth.password'),
35 | ]);
36 | }
37 |
38 | $request->session()->put('auth.password_confirmed_at', time());
39 |
40 | return redirect()->intended('/dashboard');
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/TextInput.jsx:
--------------------------------------------------------------------------------
1 | import { forwardRef, useEffect, useRef } from 'react';
2 |
3 | export default forwardRef(function TextInput(
4 | { type = 'text', name, id, value, className, autoComplete, required, isFocused, handleChange },
5 | ref
6 | ) {
7 | const input = ref ? ref : useRef();
8 |
9 | useEffect(() => {
10 | if (isFocused) {
11 | input.current.focus();
12 | }
13 | }, []);
14 |
15 | return (
16 |
17 | handleChange(e)}
30 | />
31 |
32 | );
33 | });
34 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/auth/login.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | @if (Route::has('password.request'))
14 |
15 | {{ __('Forgot your password?') }}
16 |
17 | @endif
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/ResponsiveNavLink.jsx:
--------------------------------------------------------------------------------
1 | import { Link } from '@inertiajs/inertia-react';
2 |
3 | export default function ResponsiveNavLink({ method = 'get', as = 'a', href, active = false, children }) {
4 | return (
5 |
15 | {children}
16 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/ConfirmablePasswordController.php:
--------------------------------------------------------------------------------
1 | validate([
31 | 'email' => $request->user()->email,
32 | 'password' => $request->password,
33 | ])) {
34 | throw ValidationException::withMessages([
35 | 'password' => __('auth.password'),
36 | ]);
37 | }
38 |
39 | $request->session()->put('auth.password_confirmed_at', time());
40 |
41 | return redirect()->intended('/dashboard');
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php:
--------------------------------------------------------------------------------
1 | [
37 | 'user' => $request->user(),
38 | ],
39 | 'ziggy' => function () use ($request) {
40 | return array_merge((new Ziggy)->toArray(), [
41 | 'location' => $request->url(),
42 | ]);
43 | },
44 | ]);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/ResponsiveNavLink.vue:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/profile/edit.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Profile') }}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | @include('profile.partials.update-profile-information-form')
13 |
14 |
15 |
16 |
17 |
18 | @include('profile.partials.update-password-form')
19 |
20 |
21 |
22 |
23 |
24 | @include('profile.partials.delete-user-form')
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/stubs/inertia-common/pest-tests/Feature/Auth/PasswordUpdateTest.php:
--------------------------------------------------------------------------------
1 | create();
8 |
9 | $response = $this
10 | ->actingAs($user)
11 | ->patch('/profile', [
12 | 'current_password' => 'password',
13 | 'password' => 'new-password',
14 | 'password_confirmation' => 'new-password',
15 | ]);
16 |
17 | $response
18 | ->assertSessionHasNoErrors()
19 | ->assertRedirect('/profile');
20 |
21 | $this->assertTrue(Hash::check('new-password', $user->refresh()->password));
22 | });
23 |
24 | test('correct password must be provided to update password', function () {
25 | $user = User::factory()->create();
26 |
27 | $response = $this
28 | ->actingAs($user)
29 | ->from('/profile')
30 | ->patch('/profile', [
31 | 'current_password' => 'wrong-password',
32 | 'password' => 'new-password',
33 | 'password_confirmation' => 'new-password',
34 | ]);
35 |
36 | $response
37 | ->assertSessionHasErrors('current_password')
38 | ->assertRedirect('/profile');
39 | });
40 |
--------------------------------------------------------------------------------
/stubs/default/tests/Feature/Auth/PasswordConfirmationTest.php:
--------------------------------------------------------------------------------
1 | create();
16 |
17 | $response = $this->actingAs($user)->get('/confirm-password');
18 |
19 | $response->assertStatus(200);
20 | }
21 |
22 | public function test_password_can_be_confirmed()
23 | {
24 | $user = User::factory()->create();
25 |
26 | $response = $this->actingAs($user)->post('/confirm-password', [
27 | 'password' => 'password',
28 | ]);
29 |
30 | $response->assertRedirect();
31 | $response->assertSessionHasNoErrors();
32 | }
33 |
34 | public function test_password_is_not_confirmed_with_invalid_password()
35 | {
36 | $user = User::factory()->create();
37 |
38 | $response = $this->actingAs($user)->post('/confirm-password', [
39 | 'password' => 'wrong-password',
40 | ]);
41 |
42 | $response->assertSessionHasErrors();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Feature/Auth/PasswordUpdateTest.php:
--------------------------------------------------------------------------------
1 | create();
8 |
9 | $response = $this
10 | ->actingAs($user)
11 | ->from('/profile')
12 | ->put('/password', [
13 | 'current_password' => 'password',
14 | 'password' => 'new-password',
15 | 'password_confirmation' => 'new-password',
16 | ]);
17 |
18 | $response
19 | ->assertSessionHasNoErrors()
20 | ->assertRedirect('/profile');
21 |
22 | $this->assertTrue(Hash::check('new-password', $user->refresh()->password));
23 | });
24 |
25 | test('correct password must be provided to update password', function () {
26 | $user = User::factory()->create();
27 |
28 | $response = $this
29 | ->actingAs($user)
30 | ->from('/profile')
31 | ->put('/password', [
32 | 'current_password' => 'wrong-password',
33 | 'password' => 'new-password',
34 | 'password_confirmation' => 'new-password',
35 | ]);
36 |
37 | $response
38 | ->assertSessionHasErrorsIn('updatePassword', 'current_password')
39 | ->assertRedirect('/profile');
40 | });
41 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/layouts/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
{{ config('app.name', 'Laravel') }}
9 |
10 |
11 |
12 |
13 |
14 | @vite(['resources/css/app.css', 'resources/js/app.js'])
15 |
16 |
17 |
18 | @include('layouts.navigation')
19 |
20 |
21 | @if (isset($header))
22 |
23 |
24 | {{ $header }}
25 |
26 |
27 | @endif
28 |
29 |
30 |
31 | {{ $slot }}
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/AuthenticatedSessionController.php:
--------------------------------------------------------------------------------
1 | authenticate();
30 |
31 | $request->session()->regenerate();
32 |
33 | return redirect()->intended('/dashboard');
34 | }
35 |
36 | /**
37 | * Destroy an authenticated session.
38 | *
39 | * @return \Illuminate\Http\RedirectResponse
40 | */
41 | public function destroy(Request $request)
42 | {
43 | Auth::guard('web')->logout();
44 |
45 | $request->session()->invalidate();
46 |
47 | $request->session()->regenerateToken();
48 |
49 | return redirect('/');
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Controllers/Auth/RegisteredUserController.php:
--------------------------------------------------------------------------------
1 | validate([
25 | 'name' => ['required', 'string', 'max:255'],
26 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
27 | 'password' => ['required', 'confirmed', Rules\Password::defaults()],
28 | ]);
29 |
30 | $user = User::create([
31 | 'name' => $request->name,
32 | 'email' => $request->email,
33 | 'password' => Hash::make($request->password),
34 | ]);
35 |
36 | event(new Registered($user));
37 |
38 | Auth::login($user);
39 |
40 | return response()->noContent();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/profile/partials/update-password-form.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | @if (session('status') === 'password-updated')
21 |
{{ __('Saved.') }}
22 | @endif
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Controllers/Auth/PasswordResetLinkController.php:
--------------------------------------------------------------------------------
1 | validate([
22 | 'email' => ['required', 'email'],
23 | ]);
24 |
25 | // We will send the password reset link to this user. Once we have attempted
26 | // to send the link, we will examine the response then see the message we
27 | // need to show to the user. Finally, we'll send out a proper response.
28 | $status = Password::sendResetLink(
29 | $request->only('email')
30 | );
31 |
32 | if ($status != Password::RESET_LINK_SENT) {
33 | throw ValidationException::withMessages([
34 | 'email' => [__($status)],
35 | ]);
36 | }
37 |
38 | return response()->json(['status' => __($status)]);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/auth/confirm-password.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{ __('This is a secure area of the application. Please confirm your password before continuing.') }}
11 |
12 |
13 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/stubs/api/pest-tests/Feature/Auth/EmailVerificationTest.php:
--------------------------------------------------------------------------------
1 | create([
10 | 'email_verified_at' => null,
11 | ]);
12 |
13 | Event::fake();
14 |
15 | $verificationUrl = URL::temporarySignedRoute(
16 | 'verification.verify',
17 | now()->addMinutes(60),
18 | ['id' => $user->id, 'hash' => sha1($user->email)]
19 | );
20 |
21 | $response = $this->actingAs($user)->get($verificationUrl);
22 |
23 | Event::assertDispatched(Verified::class);
24 | expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
25 | $response->assertRedirect(config('app.frontend_url').'/dashboard?verified=1');
26 | });
27 |
28 | test('email is not verified with invalid hash', function () {
29 | $user = User::factory()->create([
30 | 'email_verified_at' => null,
31 | ]);
32 |
33 | $verificationUrl = URL::temporarySignedRoute(
34 | 'verification.verify',
35 | now()->addMinutes(60),
36 | ['id' => $user->id, 'hash' => sha1('wrong-email')]
37 | );
38 |
39 | $this->actingAs($user)->get($verificationUrl);
40 |
41 | expect($user->fresh()->hasVerifiedEmail())->toBeFalse();
42 | });
43 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/auth/verify-email.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }}
5 |
6 |
7 | @if (session('status') == 'verification-link-sent')
8 |
9 | {{ __('A new verification link has been sent to the email address you provided during registration.') }}
10 |
11 | @endif
12 |
13 |
14 |
15 |
16 |
17 |
18 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/stubs/splade/dusk-tests/Auth/RegistrationTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) {
16 | $browser->logout()
17 | ->visit('/register')
18 | ->waitForInput('name')
19 | ->assertInputPresent('name')
20 | ->assertInputPresent('email')
21 | ->assertInputPresent('password')
22 | ->assertInputPresent('password_confirmation');
23 | });
24 | }
25 |
26 | public function test_new_users_can_register()
27 | {
28 | $this->browse(function (Browser $browser) {
29 | $browser->logout()
30 | ->visit('/register')
31 | ->waitForInput('name')
32 | ->type('name', 'Test User')
33 | ->type('email', 'test@example.com')
34 | ->type('password', 'password')
35 | ->type('password_confirmation', 'password')
36 | ->press('Register')
37 | ->waitForLocation('/dashboard')
38 | ->assertAuthenticated();
39 | });
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/stubs/splade/dusk-tests/.env.dusk:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=base64:xcEnu4C/PJvhan7I0PnHK/hAqVclnMU9ANW+LSXDVO4=
4 | APP_DEBUG=true
5 | APP_URL=http://127.0.0.1:8000
6 |
7 | LOG_CHANNEL=stack
8 | LOG_DEPRECATIONS_CHANNEL=null
9 | LOG_LEVEL=debug
10 |
11 | DB_CONNECTION=sqlite
12 | # DB_HOST=127.0.0.1
13 | # DB_PORT=3306
14 | # DB_DATABASE=splade
15 | # DB_USERNAME=root
16 | # DB_PASSWORD=
17 |
18 | BROADCAST_DRIVER=log
19 | CACHE_DRIVER=file
20 | FILESYSTEM_DISK=local
21 | QUEUE_CONNECTION=sync
22 | SESSION_DRIVER=file
23 | SESSION_LIFETIME=120
24 |
25 | MEMCACHED_HOST=127.0.0.1
26 |
27 | REDIS_HOST=127.0.0.1
28 | REDIS_PASSWORD=null
29 | REDIS_PORT=6379
30 |
31 | MAIL_MAILER=smtp
32 | MAIL_HOST=mailhog
33 | MAIL_PORT=1025
34 | MAIL_USERNAME=null
35 | MAIL_PASSWORD=null
36 | MAIL_ENCRYPTION=null
37 | MAIL_FROM_ADDRESS="hello@example.com"
38 | MAIL_FROM_NAME="${APP_NAME}"
39 |
40 | AWS_ACCESS_KEY_ID=
41 | AWS_SECRET_ACCESS_KEY=
42 | AWS_DEFAULT_REGION=us-east-1
43 | AWS_BUCKET=
44 | AWS_USE_PATH_STYLE_ENDPOINT=false
45 |
46 | PUSHER_APP_ID=
47 | PUSHER_APP_KEY=
48 | PUSHER_APP_SECRET=
49 | PUSHER_HOST=
50 | PUSHER_PORT=443
51 | PUSHER_SCHEME=https
52 | PUSHER_APP_CLUSTER=mt1
53 |
54 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
55 | VITE_PUSHER_HOST="${PUSHER_HOST}"
56 | VITE_PUSHER_PORT="${PUSHER_PORT}"
57 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
58 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
59 |
60 | DUSK_FAKE_NOTIFICATIONS=true
--------------------------------------------------------------------------------
/stubs/default/resources/views/auth/forgot-password.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }}
11 |
12 |
13 |
14 |
15 |
16 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/stubs/inertia-common/routes/web.php:
--------------------------------------------------------------------------------
1 | Route::has('login'),
22 | 'canRegister' => Route::has('register'),
23 | 'laravelVersion' => Application::VERSION,
24 | 'phpVersion' => PHP_VERSION,
25 | ]);
26 | });
27 |
28 | Route::get('/dashboard', function () {
29 | return Inertia::render('Dashboard');
30 | })->middleware(['auth', 'verified'])->name('dashboard');
31 |
32 | Route::middleware('auth')->group(function () {
33 | Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
34 | Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
35 | Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
36 | });
37 |
38 | require __DIR__.'/auth.php';
39 |
--------------------------------------------------------------------------------
/stubs/api/tests/Feature/Auth/PasswordResetTest.php:
--------------------------------------------------------------------------------
1 | create();
20 |
21 | $this->post('/forgot-password', ['email' => $user->email]);
22 |
23 | Notification::assertSentTo($user, ResetPassword::class);
24 | }
25 |
26 | public function test_password_can_be_reset_with_valid_token()
27 | {
28 | Notification::fake();
29 |
30 | $user = User::factory()->create();
31 |
32 | $this->post('/forgot-password', ['email' => $user->email]);
33 |
34 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
35 | $response = $this->post('/reset-password', [
36 | 'token' => $notification->token,
37 | 'email' => $user->email,
38 | 'password' => 'password',
39 | 'password_confirmation' => 'password',
40 | ]);
41 |
42 | $response->assertSessionHasNoErrors();
43 |
44 | return true;
45 | });
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/stubs/api/routes/auth.php:
--------------------------------------------------------------------------------
1 | middleware('guest')
13 | ->name('register');
14 |
15 | Route::post('/login', [AuthenticatedSessionController::class, 'store'])
16 | ->middleware('guest')
17 | ->name('login');
18 |
19 | Route::post('/forgot-password', [PasswordResetLinkController::class, 'store'])
20 | ->middleware('guest')
21 | ->name('password.email');
22 |
23 | Route::post('/reset-password', [NewPasswordController::class, 'store'])
24 | ->middleware('guest')
25 | ->name('password.store');
26 |
27 | Route::get('/verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke'])
28 | ->middleware(['auth', 'signed', 'throttle:6,1'])
29 | ->name('verification.verify');
30 |
31 | Route::post('/email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
32 | ->middleware(['auth', 'throttle:6,1'])
33 | ->name('verification.send');
34 |
35 | Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])
36 | ->middleware('auth')
37 | ->name('logout');
38 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/AuthenticatedSessionController.php:
--------------------------------------------------------------------------------
1 | Route::has('password.request'),
23 | 'status' => session('status'),
24 | ]);
25 | }
26 |
27 | /**
28 | * Handle an incoming authentication request.
29 | *
30 | * @return \Illuminate\Http\RedirectResponse
31 | */
32 | public function store(LoginRequest $request)
33 | {
34 | $request->authenticate();
35 |
36 | $request->session()->regenerate();
37 |
38 | return redirect()->intended('/dashboard');
39 | }
40 |
41 | /**
42 | * Destroy an authenticated session.
43 | *
44 | * @return \Illuminate\Http\RedirectResponse
45 | */
46 | public function destroy(Request $request)
47 | {
48 | Auth::guard('web')->logout();
49 |
50 | $request->session()->invalidate();
51 |
52 | $request->session()->regenerateToken();
53 |
54 | return redirect('/');
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/PasswordResetLinkController.php:
--------------------------------------------------------------------------------
1 | validate([
31 | 'email' => ['required', 'email'],
32 | ]);
33 |
34 | // We will send the password reset link to this user. Once we have attempted
35 | // to send the link, we will examine the response then see the message we
36 | // need to show to the user. Finally, we'll send out a proper response.
37 | $status = Password::sendResetLink(
38 | $request->only('email')
39 | );
40 |
41 | return $status == Password::RESET_LINK_SENT
42 | ? back()->with('status', __($status))
43 | : back()->withInput($request->only('email'))
44 | ->withErrors(['email' => __($status)]);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/RegisteredUserController.php:
--------------------------------------------------------------------------------
1 | validate([
35 | 'name' => ['required', 'string', 'max:255'],
36 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
37 | 'password' => ['required', 'confirmed', Rules\Password::defaults()],
38 | ]);
39 |
40 | $user = User::create([
41 | 'name' => $request->name,
42 | 'email' => $request->email,
43 | 'password' => Hash::make($request->password),
44 | ]);
45 |
46 | event(new Registered($user));
47 |
48 | Auth::login($user);
49 |
50 | return redirect('/dashboard');
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/RegisteredUserController.php:
--------------------------------------------------------------------------------
1 | validate([
36 | 'name' => 'required|string|max:255',
37 | 'email' => 'required|string|email|max:255|unique:'.User::class,
38 | 'password' => ['required', 'confirmed', Rules\Password::defaults()],
39 | ]);
40 |
41 | $user = User::create([
42 | 'name' => $request->name,
43 | 'email' => $request->email,
44 | 'password' => Hash::make($request->password),
45 | ]);
46 |
47 | event(new Registered($user));
48 |
49 | Auth::login($user);
50 |
51 | return redirect('/dashboard');
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/components/dropdown.blade.php:
--------------------------------------------------------------------------------
1 | @props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white dark:bg-gray-700'])
2 |
3 | @php
4 | switch ($align) {
5 | case 'left':
6 | $alignmentClasses = 'origin-top-left left-0';
7 | break;
8 | case 'top':
9 | $alignmentClasses = 'origin-top';
10 | break;
11 | case 'right':
12 | default:
13 | $alignmentClasses = 'origin-top-right right-0';
14 | break;
15 | }
16 |
17 | switch ($width) {
18 | case '48':
19 | $width = 'w-48';
20 | break;
21 | }
22 | @endphp
23 |
24 |
25 |
26 | {{ $trigger }}
27 |
28 |
29 |
39 |
40 | {{ $content }}
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/stubs/inertia-common/tests/Feature/Auth/PasswordUpdateTest.php:
--------------------------------------------------------------------------------
1 | create();
17 |
18 | $response = $this
19 | ->actingAs($user)
20 | ->from('/profile')
21 | ->put('/password', [
22 | 'current_password' => 'password',
23 | 'password' => 'new-password',
24 | 'password_confirmation' => 'new-password',
25 | ]);
26 |
27 | $response
28 | ->assertSessionHasNoErrors()
29 | ->assertRedirect('/profile');
30 |
31 | $this->assertTrue(Hash::check('new-password', $user->refresh()->password));
32 | }
33 |
34 | public function test_correct_password_must_be_provided_to_update_password()
35 | {
36 | $user = User::factory()->create();
37 |
38 | $response = $this
39 | ->actingAs($user)
40 | ->from('/profile')
41 | ->put('/password', [
42 | 'current_password' => 'wrong-password',
43 | 'password' => 'new-password',
44 | 'password_confirmation' => 'new-password',
45 | ]);
46 |
47 | $response
48 | ->assertSessionHasErrors('current_password')
49 | ->assertRedirect('/profile');
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/stubs/default/tests/Feature/Auth/PasswordUpdateTest.php:
--------------------------------------------------------------------------------
1 | create();
17 |
18 | $response = $this
19 | ->actingAs($user)
20 | ->from('/profile')
21 | ->put('/password', [
22 | 'current_password' => 'password',
23 | 'password' => 'new-password',
24 | 'password_confirmation' => 'new-password',
25 | ]);
26 |
27 | $response
28 | ->assertSessionHasNoErrors()
29 | ->assertRedirect('/profile');
30 |
31 | $this->assertTrue(Hash::check('new-password', $user->refresh()->password));
32 | }
33 |
34 | public function test_correct_password_must_be_provided_to_update_password()
35 | {
36 | $user = User::factory()->create();
37 |
38 | $response = $this
39 | ->actingAs($user)
40 | ->from('/profile')
41 | ->put('/password', [
42 | 'current_password' => 'wrong-password',
43 | 'password' => 'new-password',
44 | 'password_confirmation' => 'new-password',
45 | ]);
46 |
47 | $response
48 | ->assertSessionHasErrorsIn('updatePassword', 'current_password')
49 | ->assertRedirect('/profile');
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Feature/Auth/EmailVerificationTest.php:
--------------------------------------------------------------------------------
1 | create([
10 | 'email_verified_at' => null,
11 | ]);
12 |
13 | $response = $this->actingAs($user)->get('/verify-email');
14 |
15 | $response->assertStatus(200);
16 | });
17 |
18 | test('email can be verified', function () {
19 | $user = User::factory()->create([
20 | 'email_verified_at' => null,
21 | ]);
22 |
23 | Event::fake();
24 |
25 | $verificationUrl = URL::temporarySignedRoute(
26 | 'verification.verify',
27 | now()->addMinutes(60),
28 | ['id' => $user->id, 'hash' => sha1($user->email)]
29 | );
30 |
31 | $response = $this->actingAs($user)->get($verificationUrl);
32 |
33 | Event::assertDispatched(Verified::class);
34 | expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
35 | $response->assertRedirect('/dashboard?verified=1');
36 | });
37 |
38 | test('email is not verified with invalid hash', function () {
39 | $user = User::factory()->create([
40 | 'email_verified_at' => null,
41 | ]);
42 |
43 | $verificationUrl = URL::temporarySignedRoute(
44 | 'verification.verify',
45 | now()->addMinutes(60),
46 | ['id' => $user->id, 'hash' => sha1('wrong-email')]
47 | );
48 |
49 | $this->actingAs($user)->get($verificationUrl);
50 |
51 | expect($user->fresh()->hasVerifiedEmail())->toBeFalse();
52 | });
53 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "protonemedia/laravel-splade-breeze",
3 | "description": "Minimal Laravel authentication scaffolding with Laravel Splade.",
4 | "keywords": [
5 | "laravel",
6 | "auth",
7 | "splade",
8 | "laravel-splade"
9 | ],
10 | "license": "MIT",
11 | "support": {
12 | "issues": "https://github.com/protonemedia/laravel-splade-breeze/issues",
13 | "source": "https://github.com/protonemedia/laravel-splade-breeze"
14 | },
15 | "authors": [
16 | {
17 | "name": "Taylor Otwell",
18 | "email": "taylor@laravel.com"
19 | },
20 | {
21 | "name": "Pascal Baljet",
22 | "email": "pascal@protone.media"
23 | }
24 | ],
25 | "require": {
26 | "php": "^8.2",
27 | "illuminate/console": "^10.48.3|^11.0",
28 | "illuminate/filesystem": "^10.48.3|^11.0",
29 | "illuminate/support": "^10.48.3|^11.0",
30 | "illuminate/validation": "^10.48.3|^11.0",
31 | "protonemedia/laravel-splade": "^1.4.18"
32 | },
33 | "autoload": {
34 | "psr-4": {
35 | "Laravel\\Breeze\\": "src/"
36 | }
37 | },
38 | "extra": {
39 | "branch-alias": {
40 | "dev-master": "1.x-dev"
41 | },
42 | "laravel": {
43 | "providers": [
44 | "Laravel\\Breeze\\BreezeServiceProvider"
45 | ]
46 | }
47 | },
48 | "config": {
49 | "sort-packages": true
50 | },
51 | "minimum-stability": "dev",
52 | "prefer-stable": true,
53 | "require-dev": {
54 | "laravel/pint": "^1.1"
55 | }
56 | }
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Pages/Profile/Edit.vue:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Profile
20 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/PasswordResetLinkController.php:
--------------------------------------------------------------------------------
1 | session('status'),
22 | ]);
23 | }
24 |
25 | /**
26 | * Handle an incoming password reset link request.
27 | *
28 | * @return \Illuminate\Http\RedirectResponse
29 | *
30 | * @throws \Illuminate\Validation\ValidationException
31 | */
32 | public function store(Request $request)
33 | {
34 | $request->validate([
35 | 'email' => 'required|email',
36 | ]);
37 |
38 | // We will send the password reset link to this user. Once we have attempted
39 | // to send the link, we will examine the response then see the message we
40 | // need to show to the user. Finally, we'll send out a proper response.
41 | $status = Password::sendResetLink(
42 | $request->only('email')
43 | );
44 |
45 | if ($status == Password::RESET_LINK_SENT) {
46 | return back()->with('status', __($status));
47 | }
48 |
49 | throw ValidationException::withMessages([
50 | 'email' => [trans($status)],
51 | ]);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/stubs/api/tests/Feature/Auth/EmailVerificationTest.php:
--------------------------------------------------------------------------------
1 | create([
19 | 'email_verified_at' => null,
20 | ]);
21 |
22 | Event::fake();
23 |
24 | $verificationUrl = URL::temporarySignedRoute(
25 | 'verification.verify',
26 | now()->addMinutes(60),
27 | ['id' => $user->id, 'hash' => sha1($user->email)]
28 | );
29 |
30 | $response = $this->actingAs($user)->get($verificationUrl);
31 |
32 | Event::assertDispatched(Verified::class);
33 | $this->assertTrue($user->fresh()->hasVerifiedEmail());
34 | $response->assertRedirect(config('app.frontend_url').'/dashboard?verified=1');
35 | }
36 |
37 | public function test_email_is_not_verified_with_invalid_hash()
38 | {
39 | $user = User::factory()->create([
40 | 'email_verified_at' => null,
41 | ]);
42 |
43 | $verificationUrl = URL::temporarySignedRoute(
44 | 'verification.verify',
45 | now()->addMinutes(60),
46 | ['id' => $user->id, 'hash' => sha1('wrong-email')]
47 | );
48 |
49 | $this->actingAs($user)->get($verificationUrl);
50 |
51 | $this->assertFalse($user->fresh()->hasVerifiedEmail());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Pages/Profile/Edit.jsx:
--------------------------------------------------------------------------------
1 | import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
2 | import DeleteUserForm from './Partials/DeleteUserForm';
3 | import UpdatePasswordForm from './Partials/UpdatePasswordForm';
4 | import UpdateProfileInformationForm from './Partials/UpdateProfileInformationForm';
5 | import { Head } from '@inertiajs/inertia-react';
6 |
7 | export default function Edit({ auth, mustVerifyEmail, status }) {
8 | return (
9 |
Profile}
12 | >
13 |
14 |
15 |
16 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | );
36 | }
37 |
--------------------------------------------------------------------------------
/stubs/splade/routes/web.php:
--------------------------------------------------------------------------------
1 | group(function () {
18 | // Registers routes to support the interactive components...
19 | Route::spladeWithVueBridge();
20 |
21 | // Registers routes to support password confirmation in Form and Link components...
22 | Route::spladePasswordConfirmation();
23 |
24 | // Registers routes to support Table Bulk Actions and Exports...
25 | Route::spladeTable();
26 |
27 | // Registers routes to support async File Uploads with Filepond...
28 | Route::spladeUploads();
29 |
30 | Route::get('/', function () {
31 | return view('welcome');
32 | });
33 |
34 | Route::middleware('auth')->group(function () {
35 | Route::get('/dashboard', function () {
36 | return view('dashboard');
37 | })->middleware(['verified'])->name('dashboard');
38 |
39 | Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
40 | Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
41 | Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
42 | });
43 |
44 | require __DIR__.'/auth.php';
45 | });
46 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/ProfileController.php:
--------------------------------------------------------------------------------
1 | $request->user(),
21 | ]);
22 | }
23 |
24 | /**
25 | * Update the user's profile information.
26 | *
27 | * @return \Illuminate\Http\RedirectResponse
28 | */
29 | public function update(ProfileUpdateRequest $request)
30 | {
31 | $request->user()->fill($request->validated());
32 |
33 | if ($request->user()->isDirty('email')) {
34 | $request->user()->email_verified_at = null;
35 | }
36 |
37 | $request->user()->save();
38 |
39 | return Redirect::route('profile.edit')->with('status', 'profile-updated');
40 | }
41 |
42 | /**
43 | * Delete the user's account.
44 | *
45 | * @return \Illuminate\Http\RedirectResponse
46 | */
47 | public function destroy(Request $request)
48 | {
49 | $request->validateWithBag('userDeletion', [
50 | 'password' => ['required', 'current-password'],
51 | ]);
52 |
53 | $user = $request->user();
54 |
55 | Auth::logout();
56 |
57 | $user->delete();
58 |
59 | $request->session()->invalidate();
60 | $request->session()->regenerateToken();
61 |
62 | return Redirect::to('/');
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/stubs/api/pest-tests/Pest.php:
--------------------------------------------------------------------------------
1 | in('Feature');
18 |
19 | /*
20 | |--------------------------------------------------------------------------
21 | | Expectations
22 | |--------------------------------------------------------------------------
23 | |
24 | | When you're writing tests, you often need to check that values meet certain conditions. The
25 | | "expect()" function gives you access to a set of "expectations" methods that you can use
26 | | to assert different things. Of course, you may extend the Expectation API at any time.
27 | |
28 | */
29 |
30 | expect()->extend('toBeOne', function () {
31 | return $this->toBe(1);
32 | });
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | Functions
37 | |--------------------------------------------------------------------------
38 | |
39 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your
40 | | project that you don't want to repeat in every file. Here you can also expose helpers as
41 | | global functions to help you to reduce the number of lines of code in your test files.
42 | |
43 | */
44 |
45 | function something()
46 | {
47 | // ..
48 | }
49 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Pest.php:
--------------------------------------------------------------------------------
1 | in('Feature');
18 |
19 | /*
20 | |--------------------------------------------------------------------------
21 | | Expectations
22 | |--------------------------------------------------------------------------
23 | |
24 | | When you're writing tests, you often need to check that values meet certain conditions. The
25 | | "expect()" function gives you access to a set of "expectations" methods that you can use
26 | | to assert different things. Of course, you may extend the Expectation API at any time.
27 | |
28 | */
29 |
30 | expect()->extend('toBeOne', function () {
31 | return $this->toBe(1);
32 | });
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | Functions
37 | |--------------------------------------------------------------------------
38 | |
39 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your
40 | | project that you don't want to repeat in every file. Here you can also expose helpers as
41 | | global functions to help you to reduce the number of lines of code in your test files.
42 | |
43 | */
44 |
45 | function something()
46 | {
47 | // ..
48 | }
49 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Pages/Auth/ConfirmPassword.vue:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | This is a secure area of the application. Please confirm your password before continuing.
26 |
27 |
28 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Feature/Auth/PasswordResetTest.php:
--------------------------------------------------------------------------------
1 | get('/forgot-password');
9 |
10 | $response->assertStatus(200);
11 | });
12 |
13 | test('reset password link can be requested', function () {
14 | Notification::fake();
15 |
16 | $user = User::factory()->create();
17 |
18 | $this->post('/forgot-password', ['email' => $user->email]);
19 |
20 | Notification::assertSentTo($user, ResetPassword::class);
21 | });
22 |
23 | test('reset password screen can be rendered', function () {
24 | Notification::fake();
25 |
26 | $user = User::factory()->create();
27 |
28 | $this->post('/forgot-password', ['email' => $user->email]);
29 |
30 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
31 | $response = $this->get('/reset-password/'.$notification->token);
32 |
33 | $response->assertStatus(200);
34 |
35 | return true;
36 | });
37 | });
38 |
39 | test('password can be reset with valid token', function () {
40 | Notification::fake();
41 |
42 | $user = User::factory()->create();
43 |
44 | $this->post('/forgot-password', ['email' => $user->email]);
45 |
46 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
47 | $response = $this->post('/reset-password', [
48 | 'token' => $notification->token,
49 | 'email' => $user->email,
50 | 'password' => 'password',
51 | 'password_confirmation' => 'password',
52 | ]);
53 |
54 | $response->assertSessionHasNoErrors();
55 |
56 | return true;
57 | });
58 | });
59 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/auth/verify-email.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }}
11 |
12 |
13 | @if (session('status') == 'verification-link-sent')
14 |
15 | {{ __('A new verification link has been sent to the email address you provided during registration.') }}
16 |
17 | @endif
18 |
19 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/ProfileController.php:
--------------------------------------------------------------------------------
1 | $request->user() instanceof MustVerifyEmail,
23 | 'status' => session('status'),
24 | ]);
25 | }
26 |
27 | /**
28 | * Update the user's profile information.
29 | *
30 | * @return \Illuminate\Http\RedirectResponse
31 | */
32 | public function update(ProfileUpdateRequest $request)
33 | {
34 | $request->user()->fill($request->validated());
35 |
36 | if ($request->user()->isDirty('email')) {
37 | $request->user()->email_verified_at = null;
38 | }
39 |
40 | $request->user()->save();
41 |
42 | return Redirect::route('profile.edit');
43 | }
44 |
45 | /**
46 | * Delete the user's account.
47 | *
48 | * @return \Illuminate\Http\RedirectResponse
49 | */
50 | public function destroy(Request $request)
51 | {
52 | $request->validate([
53 | 'password' => ['required', 'current-password'],
54 | ]);
55 |
56 | $user = $request->user();
57 |
58 | Auth::logout();
59 |
60 | $user->delete();
61 |
62 | $request->session()->invalidate();
63 | $request->session()->regenerateToken();
64 |
65 | return Redirect::to('/');
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/stubs/splade/dusk-tests/Auth/AuthenticationTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) {
17 | $browser->logout()
18 | ->visit('/login')
19 | ->waitForInput('email')
20 | ->assertInputPresent('email')
21 | ->assertInputPresent('password');
22 | });
23 | }
24 |
25 | public function test_users_can_authenticate_using_the_login_screen()
26 | {
27 | $this->browse(function (Browser $browser) {
28 | $user = User::factory()->create();
29 |
30 | $browser->logout()
31 | ->visit('/login')
32 | ->waitForInput('email')
33 | ->type('email', $user->email)
34 | ->type('password', 'password')
35 | ->press('Log in')
36 | ->waitForLocation('/dashboard')
37 | ->assertAuthenticatedAs($user);
38 | });
39 | }
40 |
41 | public function test_users_can_not_authenticate_with_invalid_password()
42 | {
43 | $this->browse(function (Browser $browser) {
44 | $user = User::factory()->create();
45 |
46 | $browser->logout()
47 | ->visit('/login')
48 | ->waitForInput('email')
49 | ->type('email', $user->email)
50 | ->type('password', 'wrong-password')
51 | ->press('Log in')
52 | ->waitForText('These credentials do not match our records.')
53 | ->assertGuest();
54 | });
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Controllers/Auth/NewPasswordController.php:
--------------------------------------------------------------------------------
1 | validate([
26 | 'token' => ['required'],
27 | 'email' => ['required', 'email'],
28 | 'password' => ['required', 'confirmed', Rules\Password::defaults()],
29 | ]);
30 |
31 | // Here we will attempt to reset the user's password. If it is successful we
32 | // will update the password on an actual user model and persist it to the
33 | // database. Otherwise we will parse the error and return the response.
34 | $status = Password::reset(
35 | $request->only('email', 'password', 'password_confirmation', 'token'),
36 | function ($user) use ($request) {
37 | $user->forceFill([
38 | 'password' => Hash::make($request->password),
39 | 'remember_token' => Str::random(60),
40 | ])->save();
41 |
42 | event(new PasswordReset($user));
43 | }
44 | );
45 |
46 | if ($status != Password::PASSWORD_RESET) {
47 | throw ValidationException::withMessages([
48 | 'email' => [__($status)],
49 | ]);
50 | }
51 |
52 | return response()->json(['status' => __($status)]);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/stubs/splade/dusk-tests/Auth/PasswordConfirmationTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) {
17 | $user = User::factory()->create();
18 |
19 | $browser->loginAs($user)
20 | ->visit('/confirm-password')
21 | ->waitForText('Please confirm your password before continuing.')
22 | ->assertInputPresent('password');
23 | });
24 | }
25 |
26 | public function test_password_can_be_confirmed()
27 | {
28 | $this->browse(function (Browser $browser) {
29 | $user = User::factory()->create();
30 |
31 | $browser->loginAs($user)
32 | ->visit('/confirm-password')
33 | ->waitForText('Please confirm your password before continuing.')
34 | ->type('password', 'password')
35 | ->press('Confirm')
36 | ->waitForLocation('/dashboard')
37 | ->assertPathIs('/dashboard');
38 | });
39 | }
40 |
41 | public function test_password_is_not_confirmed_with_invalid_password()
42 | {
43 | $this->browse(function (Browser $browser) {
44 | $user = User::factory()->create();
45 |
46 | $browser->loginAs($user)
47 | ->visit('/confirm-password')
48 | ->waitForText('Please confirm your password before continuing.')
49 | ->type('password', 'wrong-password')
50 | ->press('Confirm')
51 | ->waitForText('The provided password is incorrect.')
52 | ->assertPathIs('/confirm-password');
53 | });
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/stubs/default/tests/Feature/Auth/EmailVerificationTest.php:
--------------------------------------------------------------------------------
1 | create([
19 | 'email_verified_at' => null,
20 | ]);
21 |
22 | $response = $this->actingAs($user)->get('/verify-email');
23 |
24 | $response->assertStatus(200);
25 | }
26 |
27 | public function test_email_can_be_verified()
28 | {
29 | $user = User::factory()->create([
30 | 'email_verified_at' => null,
31 | ]);
32 |
33 | Event::fake();
34 |
35 | $verificationUrl = URL::temporarySignedRoute(
36 | 'verification.verify',
37 | now()->addMinutes(60),
38 | ['id' => $user->id, 'hash' => sha1($user->email)]
39 | );
40 |
41 | $response = $this->actingAs($user)->get($verificationUrl);
42 |
43 | Event::assertDispatched(Verified::class);
44 | $this->assertTrue($user->fresh()->hasVerifiedEmail());
45 | $response->assertRedirect('/dashboard?verified=1');
46 | }
47 |
48 | public function test_email_is_not_verified_with_invalid_hash()
49 | {
50 | $user = User::factory()->create([
51 | 'email_verified_at' => null,
52 | ]);
53 |
54 | $verificationUrl = URL::temporarySignedRoute(
55 | 'verification.verify',
56 | now()->addMinutes(60),
57 | ['id' => $user->id, 'hash' => sha1('wrong-email')]
58 | );
59 |
60 | $this->actingAs($user)->get($verificationUrl);
61 |
62 | $this->assertFalse($user->fresh()->hasVerifiedEmail());
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/stubs/splade/dusk-tests/Auth/PasswordUpdateTest.php:
--------------------------------------------------------------------------------
1 | create();
18 |
19 | $this->browse(function (Browser $browser) use ($user) {
20 | $browser->loginAs($user)
21 | ->visit('/profile')
22 | ->waitForText('Update Password')
23 | ->within('@update-password', function (Browser $browser) {
24 | $browser->type('current_password', 'password')
25 | ->type('password', 'new-password')
26 | ->type('password_confirmation', 'new-password')
27 | ->press('Save')
28 | ->waitForText('Saved');
29 | });
30 | });
31 |
32 | $this->assertTrue(Hash::check('new-password', $user->refresh()->password));
33 | }
34 |
35 | public function test_correct_password_must_be_provided_to_update_password()
36 | {
37 | $user = User::factory()->create();
38 |
39 | $this->browse(function (Browser $browser) use ($user) {
40 | $browser->loginAs($user)
41 | ->visit('/profile')
42 | ->waitForText('Update Password')
43 | ->within('@update-password', function (Browser $browser) {
44 | $browser->type('current_password', 'wrong-password')
45 | ->type('password', 'new-password')
46 | ->type('password_confirmation', 'new-password')
47 | ->press('Save')
48 | ->waitForText('The password is incorrect.');
49 | });
50 | });
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Pages/Auth/VerifyEmail.jsx:
--------------------------------------------------------------------------------
1 | import GuestLayout from '@/Layouts/GuestLayout';
2 | import PrimaryButton from '@/Components/PrimaryButton';
3 | import { Head, Link, useForm } from '@inertiajs/inertia-react';
4 |
5 | export default function VerifyEmail({ status }) {
6 | const { post, processing } = useForm();
7 |
8 | const submit = (e) => {
9 | e.preventDefault();
10 |
11 | post(route('verification.send'));
12 | };
13 |
14 | return (
15 |
16 |
17 |
18 |
19 | Thanks for signing up! Before getting started, could you verify your email address by clicking on the
20 | link we just emailed to you? If you didn't receive the email, we will gladly send you another.
21 |
22 |
23 | {status === 'verification-link-sent' && (
24 |
25 | A new verification link has been sent to the email address you provided during registration.
26 |
27 | )}
28 |
29 |
43 |
44 | );
45 | }
46 |
--------------------------------------------------------------------------------
/stubs/api/config/sanctum.php:
--------------------------------------------------------------------------------
1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
17 | '%s%s%s',
18 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
19 | env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '',
20 | env('FRONTEND_URL') ? ','.parse_url(env('FRONTEND_URL'), PHP_URL_HOST) : ''
21 | ))),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Expiration Minutes
26 | |--------------------------------------------------------------------------
27 | |
28 | | This value controls the number of minutes until an issued token will be
29 | | considered expired. If this value is null, personal access tokens do
30 | | not expire. This won't tweak the lifetime of first-party sessions.
31 | |
32 | */
33 |
34 | 'expiration' => null,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Sanctum Middleware
39 | |--------------------------------------------------------------------------
40 | |
41 | | When authenticating your first-party SPA with Sanctum you may need to
42 | | customize some of the middleware Sanctum uses while processing the
43 | | request. You may change the middleware listed below as required.
44 | |
45 | */
46 |
47 | 'middleware' => [
48 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
49 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Pages/Auth/ForgotPassword.vue:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | Forgot your password? No problem. Just let us know your email address and we will email you a password reset
28 | link that will allow you to choose a new one.
29 |
30 |
31 |
32 | {{ status }}
33 |
34 |
35 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Pages/Auth/VerifyEmail.vue:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | Thanks for signing up! Before getting started, could you verify your email address by clicking on the link
26 | we just emailed to you? If you didn't receive the email, we will gladly send you another.
27 |
28 |
29 |
30 | A new verification link has been sent to the email address you provided during registration.
31 |
32 |
33 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Pages/Auth/ForgotPassword.jsx:
--------------------------------------------------------------------------------
1 | import GuestLayout from '@/Layouts/GuestLayout';
2 | import InputError from '@/Components/InputError';
3 | import PrimaryButton from '@/Components/PrimaryButton';
4 | import TextInput from '@/Components/TextInput';
5 | import { Head, useForm } from '@inertiajs/inertia-react';
6 |
7 | export default function ForgotPassword({ status }) {
8 | const { data, setData, post, processing, errors } = useForm({
9 | email: '',
10 | });
11 |
12 | const onHandleChange = (event) => {
13 | setData(event.target.name, event.target.value);
14 | };
15 |
16 | const submit = (e) => {
17 | e.preventDefault();
18 |
19 | post(route('password.email'));
20 | };
21 |
22 | return (
23 |
24 |
25 |
26 |
27 | Forgot your password? No problem. Just let us know your email address and we will email you a password
28 | reset link that will allow you to choose a new one.
29 |
30 |
31 | {status &&
{status}
}
32 |
33 |
52 |
53 | );
54 | }
55 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/auth/reset-password.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/stubs/default/tests/Feature/Auth/PasswordResetTest.php:
--------------------------------------------------------------------------------
1 | get('/forgot-password');
18 |
19 | $response->assertStatus(200);
20 | }
21 |
22 | public function test_reset_password_link_can_be_requested()
23 | {
24 | Notification::fake();
25 |
26 | $user = User::factory()->create();
27 |
28 | $this->post('/forgot-password', ['email' => $user->email]);
29 |
30 | Notification::assertSentTo($user, ResetPassword::class);
31 | }
32 |
33 | public function test_reset_password_screen_can_be_rendered()
34 | {
35 | Notification::fake();
36 |
37 | $user = User::factory()->create();
38 |
39 | $this->post('/forgot-password', ['email' => $user->email]);
40 |
41 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
42 | $response = $this->get('/reset-password/'.$notification->token);
43 |
44 | $response->assertStatus(200);
45 |
46 | return true;
47 | });
48 | }
49 |
50 | public function test_password_can_be_reset_with_valid_token()
51 | {
52 | Notification::fake();
53 |
54 | $user = User::factory()->create();
55 |
56 | $this->post('/forgot-password', ['email' => $user->email]);
57 |
58 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
59 | $response = $this->post('/reset-password', [
60 | 'token' => $notification->token,
61 | 'email' => $user->email,
62 | 'password' => 'password',
63 | 'password_confirmation' => 'password',
64 | ]);
65 |
66 | $response->assertSessionHasNoErrors();
67 |
68 | return true;
69 | });
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Pages/Auth/ConfirmPassword.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect } from 'react';
2 | import GuestLayout from '@/Layouts/GuestLayout';
3 | import InputError from '@/Components/InputError';
4 | import InputLabel from '@/Components/InputLabel';
5 | import PrimaryButton from '@/Components/PrimaryButton';
6 | import TextInput from '@/Components/TextInput';
7 | import { Head, useForm } from '@inertiajs/inertia-react';
8 |
9 | export default function ConfirmPassword() {
10 | const { data, setData, post, processing, errors, reset } = useForm({
11 | password: '',
12 | });
13 |
14 | useEffect(() => {
15 | return () => {
16 | reset('password');
17 | };
18 | }, []);
19 |
20 | const onHandleChange = (event) => {
21 | setData(event.target.name, event.target.value);
22 | };
23 |
24 | const submit = (e) => {
25 | e.preventDefault();
26 |
27 | post(route('password.confirm'));
28 | };
29 |
30 | return (
31 |
32 |
33 |
34 |
35 | This is a secure area of the application. Please confirm your password before continuing.
36 |
37 |
38 |
61 |
62 | );
63 | }
64 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/profile/partials/update-password-form.blade.php:
--------------------------------------------------------------------------------
1 |
49 |
--------------------------------------------------------------------------------
/stubs/splade/resources/views/profile/partials/update-profile-information-form.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 | @if ($user instanceof \Illuminate\Contracts\Auth\MustVerifyEmail && ! $user->hasVerifiedEmail())
17 |
18 |
19 | {{ __('Your email address is unverified.') }}
20 |
21 |
22 | {{ __('Click here to re-send the verification email.') }}
23 |
24 |
25 |
26 | @if (session('status') === 'verification-link-sent')
27 |
28 | {{ __('A new verification link has been sent to your email address.') }}
29 |
30 | @endif
31 |
32 | @endif
33 |
34 |
35 |
36 |
37 | @if (session('status') === 'profile-updated')
38 |
39 | {{ __('Saved.') }}
40 |
41 | @endif
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/stubs/splade/routes/auth.php:
--------------------------------------------------------------------------------
1 | group(function () {
15 | Route::get('register', [RegisteredUserController::class, 'create'])->name('register');
16 | Route::post('register', [RegisteredUserController::class, 'store']);
17 |
18 | Route::get('login', [AuthenticatedSessionController::class, 'create'])->name('login');
19 | Route::post('login', [AuthenticatedSessionController::class, 'store']);
20 |
21 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])->name('password.request');
22 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])->name('password.email');
23 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create'])->name('password.reset');
24 | Route::post('reset-password', [NewPasswordController::class, 'store'])->name('password.store');
25 | });
26 |
27 | Route::middleware('auth')->group(function () {
28 | Route::get('verify-email', [EmailVerificationPromptController::class, '__invoke'])->name('verification.notice');
29 | Route::get('verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke'])->middleware(['signed', 'throttle:6,1'])->name('verification.verify');
30 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store'])->middleware('throttle:6,1')->name('verification.send');
31 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show'])->name('password.confirm');
32 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']);
33 |
34 | Route::put('password', [PasswordController::class, 'update'])->name('password.update');
35 |
36 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])->name('logout');
37 | });
38 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/profile/partials/delete-user-form.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ __('Delete Account') }}
5 |
6 |
7 |
8 | {{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.') }}
9 |
10 |
11 |
12 | {{ __('Delete Account') }}
16 |
17 |
18 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/stubs/inertia-common/pest-tests/Feature/ProfileTest.php:
--------------------------------------------------------------------------------
1 | create();
7 |
8 | $response = $this
9 | ->actingAs($user)
10 | ->get('/profile');
11 |
12 | $response->assertOk();
13 | });
14 |
15 | test('profile information can be updated', function () {
16 | $user = User::factory()->create();
17 |
18 | $response = $this
19 | ->actingAs($user)
20 | ->patch('/profile', [
21 | 'name' => 'Test User',
22 | 'email' => 'test@example.com',
23 | ]);
24 |
25 | $response
26 | ->assertSessionHasNoErrors()
27 | ->assertRedirect('/profile');
28 |
29 | $user->refresh();
30 |
31 | $this->assertSame('Test User', $user->name);
32 | $this->assertSame('test@example.com', $user->email);
33 | $this->assertNull($user->email_verified_at);
34 | });
35 |
36 | test('email verification status is unchanged when the email address is unchanged', function () {
37 | $user = User::factory()->create();
38 |
39 | $response = $this
40 | ->actingAs($user)
41 | ->patch('/profile', [
42 | 'name' => 'Test User',
43 | 'email' => $user->email,
44 | ]);
45 |
46 | $response
47 | ->assertSessionHasNoErrors()
48 | ->assertRedirect('/profile');
49 |
50 | $this->assertNotNull($user->refresh()->email_verified_at);
51 | });
52 |
53 | test('user can delete their account', function () {
54 | $user = User::factory()->create();
55 |
56 | $response = $this
57 | ->actingAs($user)
58 | ->delete('/profile', [
59 | 'password' => 'password',
60 | ]);
61 |
62 | $response
63 | ->assertSessionHasNoErrors()
64 | ->assertRedirect('/');
65 |
66 | $this->assertGuest();
67 | $this->assertNull($user->fresh());
68 | });
69 |
70 | test('correct password must be provided to delete account', function () {
71 | $user = User::factory()->create();
72 |
73 | $response = $this
74 | ->actingAs($user)
75 | ->from('/profile')
76 | ->delete('/profile', [
77 | 'password' => 'wrong-password',
78 | ]);
79 |
80 | $response
81 | ->assertSessionHasErrors('password')
82 | ->assertRedirect('/profile');
83 |
84 | $this->assertNotNull($user->fresh());
85 | });
86 |
--------------------------------------------------------------------------------
/stubs/inertia-react/resources/js/Components/Modal.jsx:
--------------------------------------------------------------------------------
1 | import { Fragment } from 'react';
2 | import { Dialog, Transition } from '@headlessui/react';
3 |
4 | export default function Modal({ children, show = false, maxWidth = '2xl', closeable = true, onClose = () => {} }) {
5 | const close = () => {
6 | if (closeable) {
7 | onClose();
8 | }
9 | };
10 |
11 | const maxWidthClass = {
12 | sm: 'sm:max-w-sm',
13 | md: 'sm:max-w-md',
14 | lg: 'sm:max-w-lg',
15 | xl: 'sm:max-w-xl',
16 | '2xl': 'sm:max-w-2xl',
17 | }[maxWidth];
18 |
19 | return (
20 |
21 |
27 |
36 |
37 |
38 |
39 |
48 |
51 | {children}
52 |
53 |
54 |
55 |
56 | );
57 | }
58 |
--------------------------------------------------------------------------------
/stubs/default/pest-tests/Feature/ProfileTest.php:
--------------------------------------------------------------------------------
1 | create();
7 |
8 | $response = $this
9 | ->actingAs($user)
10 | ->get('/profile');
11 |
12 | $response->assertOk();
13 | });
14 |
15 | test('profile information can be updated', function () {
16 | $user = User::factory()->create();
17 |
18 | $response = $this
19 | ->actingAs($user)
20 | ->patch('/profile', [
21 | 'name' => 'Test User',
22 | 'email' => 'test@example.com',
23 | ]);
24 |
25 | $response
26 | ->assertSessionHasNoErrors()
27 | ->assertRedirect('/profile');
28 |
29 | $user->refresh();
30 |
31 | $this->assertSame('Test User', $user->name);
32 | $this->assertSame('test@example.com', $user->email);
33 | $this->assertNull($user->email_verified_at);
34 | });
35 |
36 | test('email verification status is unchanged when the email address is unchanged', function () {
37 | $user = User::factory()->create();
38 |
39 | $response = $this
40 | ->actingAs($user)
41 | ->patch('/profile', [
42 | 'name' => 'Test User',
43 | 'email' => $user->email,
44 | ]);
45 |
46 | $response
47 | ->assertSessionHasNoErrors()
48 | ->assertRedirect('/profile');
49 |
50 | $this->assertNotNull($user->refresh()->email_verified_at);
51 | });
52 |
53 | test('user can delete their account', function () {
54 | $user = User::factory()->create();
55 |
56 | $response = $this
57 | ->actingAs($user)
58 | ->delete('/profile', [
59 | 'password' => 'password',
60 | ]);
61 |
62 | $response
63 | ->assertSessionHasNoErrors()
64 | ->assertRedirect('/');
65 |
66 | $this->assertGuest();
67 | $this->assertNull($user->fresh());
68 | });
69 |
70 | test('correct password must be provided to delete account', function () {
71 | $user = User::factory()->create();
72 |
73 | $response = $this
74 | ->actingAs($user)
75 | ->from('/profile')
76 | ->delete('/profile', [
77 | 'password' => 'wrong-password',
78 | ]);
79 |
80 | $response
81 | ->assertSessionHasErrorsIn('userDeletion', 'password')
82 | ->assertRedirect('/profile');
83 |
84 | $this->assertNotNull($user->fresh());
85 | });
86 |
--------------------------------------------------------------------------------
/stubs/inertia-vue/resources/js/Components/Dropdown.vue:
--------------------------------------------------------------------------------
1 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/stubs/splade/dusk-tests/Auth/EmailVerificationTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) {
18 | $user = User::factory()->create([
19 | 'email_verified_at' => null,
20 | ]);
21 |
22 | $browser->loginAs($user)
23 | ->visit('/verify-email')
24 | ->waitForText('Thanks for signing up!')
25 | ->assertSeeIn('button', 'Resend Verification Email');
26 | });
27 | }
28 |
29 | public function test_email_can_be_verified()
30 | {
31 | $this->browse(function (Browser $browser) {
32 | $user = User::factory()->create([
33 | 'email_verified_at' => null,
34 | ]);
35 |
36 | $verificationUrl = URL::temporarySignedRoute(
37 | 'verification.verify',
38 | now()->addMinutes(60),
39 | ['id' => $user->id, 'hash' => sha1($user->email)]
40 | );
41 |
42 | $browser->loginAs($user)
43 | ->visit($verificationUrl)
44 | ->waitForText('You\'re logged in!')
45 | ->assertPathIs('/dashboard')
46 | ->assertQueryStringHas('verified', 1);
47 |
48 | $this->assertTrue($user->fresh()->hasVerifiedEmail());
49 | });
50 | }
51 |
52 | public function test_email_is_not_verified_with_invalid_hash()
53 | {
54 | $this->browse(function (Browser $browser) {
55 | $user = User::factory()->create([
56 | 'email_verified_at' => null,
57 | ]);
58 |
59 | $verificationUrl = URL::temporarySignedRoute(
60 | 'verification.verify',
61 | now()->addMinutes(60),
62 | ['id' => $user->id, 'hash' => sha1('wrong-email')]
63 | );
64 |
65 | $browser->loginAs($user)
66 | ->visit($verificationUrl)
67 | ->assertSee('403');
68 |
69 | $this->assertFalse($user->fresh()->hasVerifiedEmail());
70 | });
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Controllers/Auth/NewPasswordController.php:
--------------------------------------------------------------------------------
1 | $request]);
23 | }
24 |
25 | /**
26 | * Handle an incoming new password request.
27 | *
28 | * @return \Illuminate\Http\RedirectResponse
29 | *
30 | * @throws \Illuminate\Validation\ValidationException
31 | */
32 | public function store(Request $request)
33 | {
34 | $request->validate([
35 | 'token' => ['required'],
36 | 'email' => ['required', 'email'],
37 | 'password' => ['required', 'confirmed', Rules\Password::defaults()],
38 | ]);
39 |
40 | // Here we will attempt to reset the user's password. If it is successful we
41 | // will update the password on an actual user model and persist it to the
42 | // database. Otherwise we will parse the error and return the response.
43 | $status = Password::reset(
44 | $request->only('email', 'password', 'password_confirmation', 'token'),
45 | function ($user) use ($request) {
46 | $user->forceFill([
47 | 'password' => Hash::make($request->password),
48 | 'remember_token' => Str::random(60),
49 | ])->save();
50 |
51 | event(new PasswordReset($user));
52 | }
53 | );
54 |
55 | // If the password was successfully reset, we will redirect the user back to
56 | // the application's home authenticated view. If there is an error we can
57 | // redirect them back to where they came from with their error message.
58 | return $status == Password::PASSWORD_RESET
59 | ? redirect()->route('login')->with('status', __($status))
60 | : back()->withInput($request->only('email'))
61 | ->withErrors(['email' => __($status)]);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/stubs/default/routes/auth.php:
--------------------------------------------------------------------------------
1 | group(function () {
15 | Route::get('register', [RegisteredUserController::class, 'create'])
16 | ->name('register');
17 |
18 | Route::post('register', [RegisteredUserController::class, 'store']);
19 |
20 | Route::get('login', [AuthenticatedSessionController::class, 'create'])
21 | ->name('login');
22 |
23 | Route::post('login', [AuthenticatedSessionController::class, 'store']);
24 |
25 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
26 | ->name('password.request');
27 |
28 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])
29 | ->name('password.email');
30 |
31 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create'])
32 | ->name('password.reset');
33 |
34 | Route::post('reset-password', [NewPasswordController::class, 'store'])
35 | ->name('password.store');
36 | });
37 |
38 | Route::middleware('auth')->group(function () {
39 | Route::get('verify-email', [EmailVerificationPromptController::class, '__invoke'])
40 | ->name('verification.notice');
41 |
42 | Route::get('verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke'])
43 | ->middleware(['signed', 'throttle:6,1'])
44 | ->name('verification.verify');
45 |
46 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
47 | ->middleware('throttle:6,1')
48 | ->name('verification.send');
49 |
50 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show'])
51 | ->name('password.confirm');
52 |
53 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']);
54 |
55 | Route::put('password', [PasswordController::class, 'update'])->name('password.update');
56 |
57 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])
58 | ->name('logout');
59 | });
60 |
--------------------------------------------------------------------------------
/stubs/inertia-common/routes/auth.php:
--------------------------------------------------------------------------------
1 | group(function () {
15 | Route::get('register', [RegisteredUserController::class, 'create'])
16 | ->name('register');
17 |
18 | Route::post('register', [RegisteredUserController::class, 'store']);
19 |
20 | Route::get('login', [AuthenticatedSessionController::class, 'create'])
21 | ->name('login');
22 |
23 | Route::post('login', [AuthenticatedSessionController::class, 'store']);
24 |
25 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
26 | ->name('password.request');
27 |
28 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])
29 | ->name('password.email');
30 |
31 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create'])
32 | ->name('password.reset');
33 |
34 | Route::post('reset-password', [NewPasswordController::class, 'store'])
35 | ->name('password.store');
36 | });
37 |
38 | Route::middleware('auth')->group(function () {
39 | Route::get('verify-email', [EmailVerificationPromptController::class, '__invoke'])
40 | ->name('verification.notice');
41 |
42 | Route::get('verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke'])
43 | ->middleware(['signed', 'throttle:6,1'])
44 | ->name('verification.verify');
45 |
46 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
47 | ->middleware('throttle:6,1')
48 | ->name('verification.send');
49 |
50 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show'])
51 | ->name('password.confirm');
52 |
53 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']);
54 |
55 | Route::put('password', [PasswordController::class, 'update'])->name('password.update');
56 |
57 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])
58 | ->name('logout');
59 | });
60 |
--------------------------------------------------------------------------------
/stubs/api/app/Http/Requests/Auth/LoginRequest.php:
--------------------------------------------------------------------------------
1 | ['required', 'string', 'email'],
33 | 'password' => ['required', 'string'],
34 | ];
35 | }
36 |
37 | /**
38 | * Attempt to authenticate the request's credentials.
39 | *
40 | * @return void
41 | *
42 | * @throws \Illuminate\Validation\ValidationException
43 | */
44 | public function authenticate()
45 | {
46 | $this->ensureIsNotRateLimited();
47 |
48 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
49 | RateLimiter::hit($this->throttleKey());
50 |
51 | throw ValidationException::withMessages([
52 | 'email' => __('auth.failed'),
53 | ]);
54 | }
55 |
56 | RateLimiter::clear($this->throttleKey());
57 | }
58 |
59 | /**
60 | * Ensure the login request is not rate limited.
61 | *
62 | * @return void
63 | *
64 | * @throws \Illuminate\Validation\ValidationException
65 | */
66 | public function ensureIsNotRateLimited()
67 | {
68 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
69 | return;
70 | }
71 |
72 | event(new Lockout($this));
73 |
74 | $seconds = RateLimiter::availableIn($this->throttleKey());
75 |
76 | throw ValidationException::withMessages([
77 | 'email' => trans('auth.throttle', [
78 | 'seconds' => $seconds,
79 | 'minutes' => ceil($seconds / 60),
80 | ]),
81 | ]);
82 | }
83 |
84 | /**
85 | * Get the rate limiting throttle key for the request.
86 | *
87 | * @return string
88 | */
89 | public function throttleKey()
90 | {
91 | return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip());
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/stubs/default/app/Http/Requests/Auth/LoginRequest.php:
--------------------------------------------------------------------------------
1 | ['required', 'string', 'email'],
33 | 'password' => ['required', 'string'],
34 | ];
35 | }
36 |
37 | /**
38 | * Attempt to authenticate the request's credentials.
39 | *
40 | * @return void
41 | *
42 | * @throws \Illuminate\Validation\ValidationException
43 | */
44 | public function authenticate()
45 | {
46 | $this->ensureIsNotRateLimited();
47 |
48 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
49 | RateLimiter::hit($this->throttleKey());
50 |
51 | throw ValidationException::withMessages([
52 | 'email' => trans('auth.failed'),
53 | ]);
54 | }
55 |
56 | RateLimiter::clear($this->throttleKey());
57 | }
58 |
59 | /**
60 | * Ensure the login request is not rate limited.
61 | *
62 | * @return void
63 | *
64 | * @throws \Illuminate\Validation\ValidationException
65 | */
66 | public function ensureIsNotRateLimited()
67 | {
68 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
69 | return;
70 | }
71 |
72 | event(new Lockout($this));
73 |
74 | $seconds = RateLimiter::availableIn($this->throttleKey());
75 |
76 | throw ValidationException::withMessages([
77 | 'email' => trans('auth.throttle', [
78 | 'seconds' => $seconds,
79 | 'minutes' => ceil($seconds / 60),
80 | ]),
81 | ]);
82 | }
83 |
84 | /**
85 | * Get the rate limiting throttle key for the request.
86 | *
87 | * @return string
88 | */
89 | public function throttleKey()
90 | {
91 | return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip());
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/stubs/inertia-common/app/Http/Controllers/Auth/NewPasswordController.php:
--------------------------------------------------------------------------------
1 | $request->email,
26 | 'token' => $request->route('token'),
27 | ]);
28 | }
29 |
30 | /**
31 | * Handle an incoming new password request.
32 | *
33 | * @return \Illuminate\Http\RedirectResponse
34 | *
35 | * @throws \Illuminate\Validation\ValidationException
36 | */
37 | public function store(Request $request)
38 | {
39 | $request->validate([
40 | 'token' => 'required',
41 | 'email' => 'required|email',
42 | 'password' => ['required', 'confirmed', Rules\Password::defaults()],
43 | ]);
44 |
45 | // Here we will attempt to reset the user's password. If it is successful we
46 | // will update the password on an actual user model and persist it to the
47 | // database. Otherwise we will parse the error and return the response.
48 | $status = Password::reset(
49 | $request->only('email', 'password', 'password_confirmation', 'token'),
50 | function ($user) use ($request) {
51 | $user->forceFill([
52 | 'password' => Hash::make($request->password),
53 | 'remember_token' => Str::random(60),
54 | ])->save();
55 |
56 | event(new PasswordReset($user));
57 | }
58 | );
59 |
60 | // If the password was successfully reset, we will redirect the user back to
61 | // the application's home authenticated view. If there is an error we can
62 | // redirect them back to where they came from with their error message.
63 | if ($status == Password::PASSWORD_RESET) {
64 | return redirect()->route('login')->with('status', __($status));
65 | }
66 |
67 | throw ValidationException::withMessages([
68 | 'email' => [trans($status)],
69 | ]);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/stubs/default/resources/views/auth/login.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
54 |
55 |
56 |
--------------------------------------------------------------------------------