diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a7c44dd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..02419b4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/tests export-ignore +/.editorconfig export-ignore +/.php_cs.dist export-ignore +/.github export-ignore +/psalm.xml export-ignore + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4b8a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.idea +.php_cs +.php_cs.cache +.phpunit.result.cache +build +composer.lock +coverage +docs +phpunit.xml +psalm.xml +vendor +.DS_Store diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..1c4e7d5 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,37 @@ +notPath('bootstrap/*') + ->notPath('storage/*') + ->notPath('resources/view/mail/*') + ->in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sortAlgorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline_array' => true, + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ] + ]) + ->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7577be8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to `fortify-ui-preset` will be documented in this file + +## 1.0.0 - 202X-XX-XX + +- initial release diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..920845b --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Your Name + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..137be47 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +

+ +# Using this template + +Here are the steps to customize this template with your preset + +- Rename the files in the `src` directory. Example `FortifyUIBootstrapCommand.php` + - Make sure you update any `use` statements and namespaces +- Add your preset stubs to the `stubs` directory +- Add your preset image and preset screenshots +- Update the `composer.json` + - Replace all instances of `YourNamespace\\FortifyUIPreset` with your details. For example: `SomeDude\\FortifyUIBootstrap` +- Search & Replace all of the following terms + - YourNamespace + - yournamespace + - YourPreset + - yourpreset + - SomeFramework + - Your Name + - yourusername + - you@yourdomain.com + + +# Introduction + +**YourPreset** is a Laravel Fortify UI preset, built with SomeFramework. + +- [Requirements](#requirements) +- [Installation](#installation) + + +## Requirements + +This package requires Laravel Fortify and FortifyUI. Installing [*FortifyUI*](https://github.com/zacksmash/fortify-ui) will automatically install and configure Laravel Fortify for you, so you may start there. + + +## Installation + +To get started, you'll need to install **YourPreset** using Composer. + +```bash +composer require yournamespace/fortify-yourpreset +``` + +Next, you'll need to run the install command: + +```bash +php artisan fortify-ui:yourpreset +``` + +This command will publish **YourPreset's** views and resources to your project. + +- All `auth` views +- Other files... + +

+ +## License + +**FortifyUIPreset** is open-sourced software licensed under the [MIT license](LICENSE.md). diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3f933a5 --- /dev/null +++ b/composer.json @@ -0,0 +1,56 @@ +{ + "name": "yournamespace/fortify-yourpreset", + "description": "Fortify-driven Laravel UI replacement", + "keywords": [ + "fortify-ui" + ], + "homepage": "https://github.com/yourusername/fortify-yourpreset", + "license": "MIT", + "authors": [ + { + "name": "Your Name", + "email": "you@yourdomain.com", + "homepage": "https://yourusername.github.io", + "role": "Developer" + } + ], + "require": { + "php": "^7.4", + "illuminate/contracts": "^8.0", + "zacksmash/fortify-ui": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16", + "orchestra/testbench": "^6.0", + "phpunit/phpunit": "^9.3", + "vimeo/psalm": "^3.11" + }, + "autoload": { + "psr-4": { + "YourNamespace\\FortifyUIPreset\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "YourNamespace\\FortifyUIPreset\\Tests\\": "tests" + } + }, + "scripts": { + "psalm": "vendor/bin/psalm", + "test": "vendor/bin/phpunit --colors=always", + "test-coverage": "vendor/bin/phpunit --coverage-html coverage", + "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" + }, + "config": { + "sort-packages": true + }, + "extra": { + "laravel": { + "providers": [ + "YourNamespace\\FortifyUIPreset\\FortifyUIPresetServiceProvider" + ] + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/fortify-preset-image.png b/fortify-preset-image.png new file mode 100644 index 0000000..a45713e Binary files /dev/null and b/fortify-preset-image.png differ diff --git a/fortify-preset-screenshot.png b/fortify-preset-screenshot.png new file mode 100644 index 0000000..800cd09 Binary files /dev/null and b/fortify-preset-screenshot.png differ diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..bbf1419 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + tests + + + + + ./src + + + + + + + + + + + diff --git a/psalm.xml.dist b/psalm.xml.dist new file mode 100644 index 0000000..c6df33e --- /dev/null +++ b/psalm.xml.dist @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/src/Commands/FortifyUIPresetCommand.php b/src/Commands/FortifyUIPresetCommand.php new file mode 100644 index 0000000..821dd7b --- /dev/null +++ b/src/Commands/FortifyUIPresetCommand.php @@ -0,0 +1,24 @@ +publishAssets(); + + $this->comment('YourPreset is now installed.'); + } + + protected function publishAssets() + { + $this->callSilent('vendor:publish', ['--tag' => 'fortify-ui-preset-resources', '--force' => true]); + } +} diff --git a/src/FortifyUIPresetServiceProvider.php b/src/FortifyUIPresetServiceProvider.php new file mode 100644 index 0000000..e173d1c --- /dev/null +++ b/src/FortifyUIPresetServiceProvider.php @@ -0,0 +1,23 @@ +app->runningInConsole()) { + $this->publishes([ + __DIR__ . '/../stubs/resources/views' => base_path('resources/views'), + // Add more resources here + ], 'fortify-ui-preset-resources'); + + $this->commands([ + FortifyUIPresetCommand::class, + ]); + } + } +} diff --git a/stubs/resources/views/auth/confirm-password.blade.php b/stubs/resources/views/auth/confirm-password.blade.php new file mode 100644 index 0000000..984c3d9 --- /dev/null +++ b/stubs/resources/views/auth/confirm-password.blade.php @@ -0,0 +1,36 @@ +@extends('layouts.app') + +@section('content') + @if ($errors->any()) +
+
{{ __('Whoops! Something went wrong.') }}
+ + +
+ @endif + +
+ @csrf + +
+ + +
+ +
+ +
+ + @if (Route::has('password.request')) + + {{ __('Forgot Your Password?') }} + + @endif +
+@endsection diff --git a/stubs/resources/views/auth/forgot-password.blade.php b/stubs/resources/views/auth/forgot-password.blade.php new file mode 100644 index 0000000..8e81622 --- /dev/null +++ b/stubs/resources/views/auth/forgot-password.blade.php @@ -0,0 +1,40 @@ +@extends('layouts.app') + +@section('content') +
+ {{ __('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.') }} +
+ + @if (session('status')) +
+ {{ session('status') }} +
+ @endif + + @if ($errors->any()) +
+
{{ __('Whoops! Something went wrong.') }}
+ + +
+ @endif + +
+ @csrf + +
+ + +
+ +
+ +
+
+@endsection diff --git a/stubs/resources/views/auth/login.blade.php b/stubs/resources/views/auth/login.blade.php new file mode 100644 index 0000000..e1657e4 --- /dev/null +++ b/stubs/resources/views/auth/login.blade.php @@ -0,0 +1,52 @@ +@extends('layouts.app') + +@section('content') + @if (session('status')) +
+ {{ session('status') }} +
+ @endif + + @if ($errors->any()) +
+
{{ __('Whoops! Something went wrong.') }}
+ + +
+ @endif + +
+ @csrf + +
+ + +
+ +
+ + +
+ +
+ + +
+ + @if (Route::has('password.request')) + + {{ __('Forgot your password?') }} + + @endif + +
+ +
+
+@endsection diff --git a/stubs/resources/views/auth/register.blade.php b/stubs/resources/views/auth/register.blade.php new file mode 100644 index 0000000..56b8356 --- /dev/null +++ b/stubs/resources/views/auth/register.blade.php @@ -0,0 +1,49 @@ +@extends('layouts.app') + +@section('content') + @if ($errors->any()) +
+
{{ __('Whoops! Something went wrong.') }}
+ + +
+ @endif + +
+ @csrf + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + {{ __('Already registered?') }} + + +
+ +
+
+@endsection diff --git a/stubs/resources/views/auth/reset-password.blade.php b/stubs/resources/views/auth/reset-password.blade.php new file mode 100644 index 0000000..2de121a --- /dev/null +++ b/stubs/resources/views/auth/reset-password.blade.php @@ -0,0 +1,42 @@ +@extends('layouts.app') + +@section('content') + @if ($errors->any()) +
+
{{ __('Whoops! Something went wrong.') }}
+ + +
+ @endif + +
+ @csrf + + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+@endsection diff --git a/stubs/resources/views/auth/two-factor-challenge.blade.php b/stubs/resources/views/auth/two-factor-challenge.blade.php new file mode 100644 index 0000000..438fea9 --- /dev/null +++ b/stubs/resources/views/auth/two-factor-challenge.blade.php @@ -0,0 +1,47 @@ +@if ($errors->any()) +
+
{{ __('Whoops! Something went wrong.') }}
+ + +
+@endif + +
+ @csrf + + {{-- + Do not show both of these fields, together. It's recommended + that you only show one field at a time and use some logic + to toggle the visibility of each field + --}} + +
+ {{ __('Please confirm access to your account by entering the authentication code provided by your authenticator application.') }} +
+ +
+ + +
+ + {{-- ** OR ** --}} + +
+ {{ __('Please confirm access to your account by entering one of your emergency recovery codes.') }} +
+ +
+ + +
+ +
+ +
+
diff --git a/stubs/resources/views/auth/verify-email.blade.php b/stubs/resources/views/auth/verify-email.blade.php new file mode 100644 index 0000000..91270a8 --- /dev/null +++ b/stubs/resources/views/auth/verify-email.blade.php @@ -0,0 +1,29 @@ +@extends('layouts.app') + +@section('content') +
+ {{ __('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.') }} +
+ + @if (session('status') == 'verification-link-sent') +
+ {{ __('A new verification link has been sent to the email address you provided during registration.') }} +
+ @endif + +
+ @csrf + + +
+ +
+ @csrf + + +
+@endsection diff --git a/stubs/resources/views/home.blade.php b/stubs/resources/views/home.blade.php new file mode 100644 index 0000000..6ae81d6 --- /dev/null +++ b/stubs/resources/views/home.blade.php @@ -0,0 +1,31 @@ +@extends('layouts.app') + +@section('content') + @if (session('status')) +
{{ session('status') }}
+ @endif + +
You are logged in!
+ +
+ @csrf + + +
+ +
+ + @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::updateProfileInformation())) + @include('profile.update-profile-information-form') + @endif + + @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::updatePasswords())) + @include('profile.update-password-form') + @endif + + @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::twoFactorAuthentication())) + @include('profile.two-factor-authentication-form') + @endif +@endsection diff --git a/stubs/resources/views/layouts/app.blade.php b/stubs/resources/views/layouts/app.blade.php new file mode 100644 index 0000000..86e2533 --- /dev/null +++ b/stubs/resources/views/layouts/app.blade.php @@ -0,0 +1,15 @@ + + + + + + + + + + {{ config('app.name', 'Laravel') }} + + + @yield('content') + + diff --git a/stubs/resources/views/profile/two-factor-authentication-form.blade.php b/stubs/resources/views/profile/two-factor-authentication-form.blade.php new file mode 100644 index 0000000..3429898 --- /dev/null +++ b/stubs/resources/views/profile/two-factor-authentication-form.blade.php @@ -0,0 +1,52 @@ +@if(! auth()->user()->two_factor_secret) + {{-- Enable 2FA --}} +
+ @csrf + + +
+@else + {{-- Disable 2FA --}} +
+ @csrf + @method('DELETE') + + +
+ + @if(session('status') == 'two-factor-authentication-enabled') + {{-- Show SVG QR Code, After Enabling 2FA --}} +
+ {{ __('Two factor authentication is now enabled. Scan the following QR code using your phone\'s authenticator application.') }} +
+ +
+ {!! auth()->user()->twoFactorQrCodeSvg() !!} +
+ @endif + + {{-- Show 2FA Recovery Codes --}} +
+ {{ __('Store these recovery codes in a secure password manager. They can be used to recover access to your account if your two factor authentication device is lost.') }} +
+ +
+ @foreach (json_decode(decrypt(auth()->user()->two_factor_recovery_codes), true) as $code) +
{{ $code }}
+ @endforeach +
+ + {{-- Regenerate 2FA Recovery Codes --}} +
+ @csrf + + +
+@endif +
diff --git a/stubs/resources/views/profile/update-password-form.blade.php b/stubs/resources/views/profile/update-password-form.blade.php new file mode 100644 index 0000000..72c16e1 --- /dev/null +++ b/stubs/resources/views/profile/update-password-form.blade.php @@ -0,0 +1,27 @@ +
+ @csrf + @method('PUT') + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ +
diff --git a/stubs/resources/views/profile/update-profile-information-form.blade.php b/stubs/resources/views/profile/update-profile-information-form.blade.php new file mode 100644 index 0000000..6e2ff01 --- /dev/null +++ b/stubs/resources/views/profile/update-profile-information-form.blade.php @@ -0,0 +1,22 @@ +
+ @csrf + @method('PUT') + +
+ + +
+ +
+ + +
+ +
+ +
+
+ +
diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php new file mode 100644 index 0000000..3105839 --- /dev/null +++ b/tests/ExampleTest.php @@ -0,0 +1,12 @@ +assertTrue(true); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..0237dbe --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,20 @@ +