From ec0903d792acbc487a16f5082d533ea8cb58b7e9 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Tue, 16 Apr 2024 17:00:24 -0400 Subject: [PATCH] Adding latest update --- .github/workflows/main.yml | 45 +++++++++++ .gitignore | 2 + .styleci.yml | 4 + CHANGELOG.md | 7 ++ CONTRIBUTING.md | 55 +++++++++++++ LICENSE.md | 21 +++++ composer.json | 57 ++++++++++++++ config/config.php | 8 ++ package.json | 22 ++++++ postcss.config.js | 6 ++ public/build/assets/scripts.js | 1 + public/build/assets/styles.css | 1 + public/build/manifest.json | 13 ++++ resources/css/auth.css | 3 + resources/js/auth.js | 12 +++ .../components/devdojoauth/button.blade.php | 51 ++++++++++++ .../components/devdojoauth/checkbox.blade.php | 17 ++++ .../components/devdojoauth/input.blade.php | 24 ++++++ .../components/devdojoauth/link.blade.php | 6 ++ .../components/devdojoauth/logo.blade.php | 1 + .../devdojoauth/text-link.blade.php | 5 ++ .../views/components/layouts/app.blade.php | 17 ++++ resources/views/pages/auth/login.blade.php | 66 ++++++++++++++++ .../pages/auth/password/[token].blade.php | 76 ++++++++++++++++++ .../pages/auth/password/confirm.blade.php | 50 ++++++++++++ .../views/pages/auth/password/reset.blade.php | 78 +++++++++++++++++++ resources/views/pages/auth/register.blade.php | 65 ++++++++++++++++ resources/views/pages/auth/verify.blade.php | 73 +++++++++++++++++ src/Auth.php | 8 ++ src/AuthFacade.php | 21 +++++ src/AuthServiceProvider.php | 77 ++++++++++++++++++ tailwind.config.js | 13 ++++ vite.config.js | 35 +++++++++ 33 files changed, 940 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 .gitignore create mode 100644 .styleci.yml create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 composer.json create mode 100644 config/config.php create mode 100644 package.json create mode 100644 postcss.config.js create mode 100644 public/build/assets/scripts.js create mode 100644 public/build/assets/styles.css create mode 100644 public/build/manifest.json create mode 100644 resources/css/auth.css create mode 100644 resources/js/auth.js create mode 100644 resources/views/components/devdojoauth/button.blade.php create mode 100644 resources/views/components/devdojoauth/checkbox.blade.php create mode 100644 resources/views/components/devdojoauth/input.blade.php create mode 100644 resources/views/components/devdojoauth/link.blade.php create mode 100644 resources/views/components/devdojoauth/logo.blade.php create mode 100644 resources/views/components/devdojoauth/text-link.blade.php create mode 100644 resources/views/components/layouts/app.blade.php create mode 100644 resources/views/pages/auth/login.blade.php create mode 100644 resources/views/pages/auth/password/[token].blade.php create mode 100644 resources/views/pages/auth/password/confirm.blade.php create mode 100644 resources/views/pages/auth/password/reset.blade.php create mode 100644 resources/views/pages/auth/register.blade.php create mode 100644 resources/views/pages/auth/verify.blade.php create mode 100644 src/Auth.php create mode 100644 src/AuthFacade.php create mode 100644 src/AuthServiceProvider.php create mode 100644 tailwind.config.js create mode 100644 vite.config.js diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..addd840 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,45 @@ +name: run-tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [7.4, 8.0] + laravel: [8.*] + stability: [prefer-lowest, prefer-stable] + include: + - laravel: 8.* + testbench: ^6.6 + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..140fd58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/ +node_modules/ diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 0000000..f4d3cbc --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,4 @@ +preset: laravel + +disabled: + - single_class_element_per_statement diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b5270a6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +All notable changes to `auth` will be documented in this file + +## 1.0.0 - 201X-XX-XX + +- initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b4ae1c4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..3f71220 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Tony Lea + +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. \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7f4ee86 --- /dev/null +++ b/composer.json @@ -0,0 +1,57 @@ +{ + "name": "devdojo/auth", + "description": "The auth package to make authentication in your laravel applications easy to use.", + "keywords": [ + "devdojo", + "auth" + ], + "homepage": "https://github.com/devdojo/auth", + "license": "MIT", + "type": "library", + "authors": [ + { + "name": "Tony Lea", + "email": "tony@devdojo.com", + "role": "Developer" + } + ], + "require": { + "php": "^7.4|^8.0|^8.1|^8.2", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0", + "laravel/folio": "^1.0", + "livewire/livewire": "^3.0", + "livewire/volt": "^1.0" + }, + "require-dev": { + "orchestra/testbench": "^6.0", + "phpunit/phpunit": "^9.0" + }, + "autoload": { + "psr-4": { + "Devdojo\\Auth\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Devdojo\\Auth\\Tests\\": "tests" + } + }, + "scripts": { + "test": "vendor/bin/phpunit", + "test-coverage": "vendor/bin/phpunit --coverage-html coverage" + + }, + "config": { + "sort-packages": true + }, + "extra": { + "laravel": { + "providers": [ + "Devdojo\\Auth\\AuthServiceProvider" + ], + "aliases": { + "Auth": "Devdojo\\Auth\\AuthFacade" + } + } + } +} diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..48d0ee9 --- /dev/null +++ b/config/config.php @@ -0,0 +1,8 @@ +:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(0px * var(--tw-space-x-reverse));margin-left:calc(0px * calc(1 - var(--tw-space-x-reverse)))}.space-x-0\.5>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.125rem * var(--tw-space-x-reverse));margin-left:calc(.125rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.rounded{border-radius:.25rem}.rounded-md{border-radius:.375rem}.border{border-width:1px}.border-gray-200\/60{border-color:#e5e7eb99}.border-gray-200\/70{border-color:#e5e7ebb3}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.border-red-300{--tw-border-opacity: 1;border-color:rgb(252 165 165 / var(--tw-border-opacity))}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity))}.bg-green-600{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.fill-current{fill:currentColor}.p-4{padding:1rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-7{padding-left:1.75rem;padding-right:1.75rem}.py-0{padding-top:0;padding-bottom:0}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-3\.5{padding-top:.875rem;padding-bottom:.875rem}.py-4{padding-top:1rem;padding-bottom:1rem}.text-center{text-align:center}.text-2xl{font-size:1.5rem;line-height:2rem}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-extrabold{font-weight:800}.font-medium{font-weight:500}.font-semibold{font-weight:600}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-9{line-height:2.25rem}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity))}.text-neutral-600{--tw-text-opacity: 1;color:rgb(82 82 82 / var(--tw-text-opacity))}.text-neutral-900{--tw-text-opacity: 1;color:rgb(23 23 23 / var(--tw-text-opacity))}.text-pink-400{--tw-text-opacity: 1;color:rgb(244 114 182 / var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}.text-red-900{--tw-text-opacity: 1;color:rgb(127 29 29 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.placeholder-red-300::-moz-placeholder{--tw-placeholder-opacity: 1;color:rgb(252 165 165 / var(--tw-placeholder-opacity))}.placeholder-red-300::placeholder{--tw-placeholder-opacity: 1;color:rgb(252 165 165 / var(--tw-placeholder-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-150{transition-duration:.15s}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}body{color:red}.placeholder\:text-gray-500::-moz-placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.placeholder\:text-gray-500::placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.hover\:bg-amber-500\/90:hover{background-color:#f59e0be6}.hover\:bg-blue-600\/90:hover{background-color:#2563ebe6}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity))}.hover\:bg-gray-900:hover{--tw-bg-opacity: 1;background-color:rgb(17 24 39 / var(--tw-bg-opacity))}.hover\:bg-green-600\/90:hover{background-color:#16a34ae6}.hover\:bg-red-600\/90:hover{background-color:#dc2626e6}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity))}.hover\:text-gray-700:hover{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.hover\:text-gray-800:hover{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity))}.focus\:border-gray-300:focus{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.focus\:border-red-300:focus{--tw-border-opacity: 1;border-color:rgb(252 165 165 / var(--tw-border-opacity))}.focus\:bg-amber-600\/90:focus{background-color:#d97706e6}.focus\:bg-blue-700\/90:focus{background-color:#1d4ed8e6}.focus\:bg-green-700\/90:focus{background-color:#15803de6}.focus\:bg-red-700\/90:focus{background-color:#b91c1ce6}.focus\:bg-white:focus{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.focus\:underline:focus{text-decoration-line:underline}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-amber-600:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(217 119 6 / var(--tw-ring-opacity))}.focus\:ring-blue-700:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(29 78 216 / var(--tw-ring-opacity))}.focus\:ring-gray-200\/60:focus{--tw-ring-color: rgb(229 231 235 / .6)}.focus\:ring-gray-900:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(17 24 39 / var(--tw-ring-opacity))}.focus\:ring-green-700:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(21 128 61 / var(--tw-ring-opacity))}.focus\:ring-red-700:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(185 28 28 / var(--tw-ring-opacity))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.active\:bg-white:active{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.peer:checked~.peer-checked\:text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity))}@media (min-width: 640px){.sm\:mx-auto{margin-left:auto;margin-right:auto}.sm\:w-full{width:100%}.sm\:max-w-md{max-width:28rem}.sm\:items-center{align-items:center}.sm\:rounded-lg{border-radius:.5rem}.sm\:border{border-width:1px}.sm\:bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.sm\:py-8{padding-top:2rem;padding-bottom:2rem}.sm\:shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}}@media (prefers-color-scheme: dark){.dark\:border-gray-200\/10{border-color:#e5e7eb1a}.dark\:border-gray-400\/10{border-color:#9ca3af1a}.dark\:border-gray-700{--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity))}.dark\:border-white\/10{border-color:#ffffff1a}.dark\:bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity))}.dark\:bg-gray-800\/50{background-color:#1f293780}.dark\:bg-green-600{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity))}.dark\:bg-white\/\[4\%\]{background-color:#ffffff0a}.dark\:text-gray-100{--tw-text-opacity: 1;color:rgb(243 244 246 / var(--tw-text-opacity))}.dark\:text-gray-200{--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity))}.dark\:text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity))}.dark\:text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.dark\:text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.dark\:text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity))}.dark\:text-green-200{--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity))}.dark\:text-neutral-400{--tw-text-opacity: 1;color:rgb(163 163 163 / var(--tw-text-opacity))}.dark\:text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.dark\:placeholder\:text-gray-400::-moz-placeholder{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.dark\:placeholder\:text-gray-400::placeholder{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.dark\:hover\:bg-gray-800\/70:hover{background-color:#1f2937b3}.dark\:hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.dark\:hover\:text-gray-300:hover{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity))}.dark\:hover\:text-gray-800:hover{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity))}.dark\:focus\:border-gray-700:focus{--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity))}.dark\:focus\:ring-gray-100:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(243 244 246 / var(--tw-ring-opacity))}.dark\:focus\:ring-gray-700:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(55 65 81 / var(--tw-ring-opacity))}.dark\:focus\:ring-white\/20:focus{--tw-ring-color: rgb(255 255 255 / .2)}.dark\:focus\:ring-offset-gray-900:focus{--tw-ring-offset-color: #111827}.peer:checked~.dark\:peer-checked\:text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity))}@media (min-width: 640px){.dark\:sm\:bg-gray-950\/50{background-color:#03071280}}}.peer:checked~.peer-checked\:\[\&_\.custom-checkbox\]\:border-gray-800 .custom-checkbox{--tw-border-opacity: 1;border-color:rgb(31 41 55 / var(--tw-border-opacity))}.peer:checked~.peer-checked\:\[\&_\.custom-checkbox\]\:bg-gray-800 .custom-checkbox{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity))}@media (prefers-color-scheme: dark){.peer:checked~.dark\:peer-checked\:\[\&_\.custom-checkbox\]\:bg-white .custom-checkbox{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}}.\[\&_svg\]\:scale-0 svg{--tw-scale-x: 0;--tw-scale-y: 0;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.peer:checked~.peer-checked\:\[\&_svg\]\:scale-100 svg{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))} diff --git a/public/build/manifest.json b/public/build/manifest.json new file mode 100644 index 0000000..8d36ee8 --- /dev/null +++ b/public/build/manifest.json @@ -0,0 +1,13 @@ +{ + "resources/css/auth.css": { + "file": "assets/styles.css", + "src": "resources/css/auth.css", + "isEntry": true + }, + "resources/js/auth.js": { + "file": "assets/scripts.js", + "name": "scripts", + "src": "resources/js/auth.js", + "isEntry": true + } +} \ No newline at end of file diff --git a/resources/css/auth.css b/resources/css/auth.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/resources/css/auth.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/resources/js/auth.js b/resources/js/auth.js new file mode 100644 index 0000000..eb3176c --- /dev/null +++ b/resources/js/auth.js @@ -0,0 +1,12 @@ +console.log('rad sauce'); + +function hello(){ + return 1+1; +} + +function helloworld2(){ + return 'hello'; +} + +helloworld2(); + diff --git a/resources/views/components/devdojoauth/button.blade.php b/resources/views/components/devdojoauth/button.blade.php new file mode 100644 index 0000000..7c60505 --- /dev/null +++ b/resources/views/components/devdojoauth/button.blade.php @@ -0,0 +1,51 @@ +@props([ + 'type' => 'primary', + 'size' => 'md', + 'tag' => 'button', + 'href' => '/', + 'submit' => false, + 'rounded' => 'full' +]) + +@php + $sizeClasses = match ($size) { + 'sm' => 'px-2.5 py-1.5 text-xs font-medium rounded-' . $rounded, + 'md' => 'px-4 py-2 text-sm font-medium rounded-' . $rounded, + 'lg' => 'px-5 py-3 text-sm font-medium rounded-' . $rounded, + 'xl' => 'px-6 py-3.5 text-base font-medium rounded-' . $rounded, + '2xl' => 'px-7 py-4 text-base font-medium rounded-' . $rounded + }; +@endphp + +@php + $typeClasses = match ($type) { + 'primary' => 'bg-gray-800 dark:bg-gray-100 text-white dark:text-gray-700 hover:bg-gray-900 dark:focus:ring-offset-gray-900 dark:focus:ring-gray-100 dark:hover:bg-white dark:hover:text-gray-800 focus:ring-2 focus:ring-gray-900 focus:ring-offset-2', + 'secondary' => 'bg-white border text-gray-500 hover:text-gray-700 border-gray-200/70 dark:focus:ring-offset-gray-900 dark:border-gray-400/10 hover:bg-gray-50 active:bg-white dark:focus:ring-gray-700 focus:bg-white focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-200/60 dark:bg-gray-800/50 dark:hover:bg-gray-800/70 dark:text-gray-400 focus:shadow-outline', + 'success' => 'bg-green-600 text-white hover:bg-green-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-green-700/90 focus:ring-green-700', + 'info' => 'bg-blue-600 text-white hover:bg-blue-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-blue-700/90 focus:ring-blue-700', + 'warning' => 'bg-amber-500 text-white hover:bg-amber-500/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-amber-600/90 focus:ring-amber-600', + 'danger' => 'bg-red-600 text-white hover:bg-red-600/90 focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-900 focus:bg-red-700/90 focus:ring-red-700', + }; +@endphp + +@php +switch ($tag ?? 'button') { + case 'button': + $tagAttr = ($submit) ? 'button type="submit"' : 'button type="button"'; + $tagClose = 'button'; + break; + case 'a': + $link = $href ?? ''; + $tagAttr = 'a href="' . $link . '"'; + $tagClose = 'a'; + break; + default: + $tagAttr = 'button type="button"'; + $tagClose = 'button'; + break; +} +@endphp + +<{!! $tagAttr !!} {!! $attributes->except(['class']) !!} class="{{ $sizeClasses }} {{ $typeClasses }} cursor-pointer inline-flex items-center w-full justify-center disabled:opacity-50 font-semibold focus:outline-none"> + {{ $slot }} + \ No newline at end of file diff --git a/resources/views/components/devdojoauth/checkbox.blade.php b/resources/views/components/devdojoauth/checkbox.blade.php new file mode 100644 index 0000000..837e538 --- /dev/null +++ b/resources/views/components/devdojoauth/checkbox.blade.php @@ -0,0 +1,17 @@ +@props([ + 'label' => null, + 'name' => null, + 'id' => null, +]) + +
+ whereStartsWith('wire:model') }} id="{{ $id ?? '' }}" name="{{ $name ?? '' }}" class="hidden peer"> + +
\ No newline at end of file diff --git a/resources/views/components/devdojoauth/input.blade.php b/resources/views/components/devdojoauth/input.blade.php new file mode 100644 index 0000000..5d62be9 --- /dev/null +++ b/resources/views/components/devdojoauth/input.blade.php @@ -0,0 +1,24 @@ +@props([ + 'label' => null, + 'id' => null, + 'name' => null, + 'type' => 'text', +]) + +@php $wireModel = $attributes->get('wire:model'); @endphp + +
+ @if($label) + + @endif + +
+ whereStartsWith('wire:model') }} id="{{ $id ?? '' }}" name="{{ $name ?? '' }}" type="{{ $type ?? '' }}" required autofocus class="appearance-none flex w-full h-10 px-3 py-2 text-sm bg-white dark:text-gray-300 dark:bg-white/[4%] border rounded-md border-gray-300 dark:border-white/10 ring-offset-background placeholder:text-gray-500 dark:placeholder:text-gray-400 focus:border-gray-300 dark:focus:border-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-200/60 dark:focus:ring-white/20 disabled:cursor-not-allowed disabled:opacity-50 @error($wireModel) border-red-300 text-red-900 placeholder-red-300 focus:border-red-300 focus:ring-red @enderror" /> +
+ + @error($wireModel) +

{{ $message }}

+ @enderror +
\ No newline at end of file diff --git a/resources/views/components/devdojoauth/link.blade.php b/resources/views/components/devdojoauth/link.blade.php new file mode 100644 index 0000000..31026fe --- /dev/null +++ b/resources/views/components/devdojoauth/link.blade.php @@ -0,0 +1,6 @@ +except('wire:navigate') }} + wire:navigate +> +{{ $slot }} + \ No newline at end of file diff --git a/resources/views/components/devdojoauth/logo.blade.php b/resources/views/components/devdojoauth/logo.blade.php new file mode 100644 index 0000000..819bf71 --- /dev/null +++ b/resources/views/components/devdojoauth/logo.blade.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/views/components/devdojoauth/text-link.blade.php b/resources/views/components/devdojoauth/text-link.blade.php new file mode 100644 index 0000000..2be3524 --- /dev/null +++ b/resources/views/components/devdojoauth/text-link.blade.php @@ -0,0 +1,5 @@ +except('wire:navigate') }} + class="text-gray-500 underline cursor-pointer dark:text-gray-400 dark:hover:text-gray-300 hover:text-gray-800"> + {{ $slot }} + \ No newline at end of file diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php new file mode 100644 index 0000000..4ea915a --- /dev/null +++ b/resources/views/components/layouts/app.blade.php @@ -0,0 +1,17 @@ + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + {{-- @vite(['packages/devdojo/auth/resources/css/auth.css', 'packages/devdojo/auth/resources/css/auth.js']) --}} + + {{ $slot }} + + \ No newline at end of file diff --git a/resources/views/pages/auth/login.blade.php b/resources/views/pages/auth/login.blade.php new file mode 100644 index 0000000..6a9d547 --- /dev/null +++ b/resources/views/pages/auth/login.blade.php @@ -0,0 +1,66 @@ + '', 'password' => '', 'remember' => false]); +rules(['email' => 'required|email', 'password' => 'required']); +name('login'); + +$authenticate = function(){ + $this->validate(); + + if (!Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) { + $this->addError('email', trans('auth.failed')); + + return; + } + + event(new Login(auth()->guard('web'), User::where('email', $this->email)->first(), $this->remember)); + + return redirect()->intended('/'); +} + +?> + + + +
+ +
+ + + + +

Sign in to your account

+
+ Or + create a new account +
+
+ +
+
+ @volt('auth.login') +
+ + + + +
+ + Forgot your password? +
+ + Sign in + + @endvolt +
+
+ +
+ +
\ No newline at end of file diff --git a/resources/views/pages/auth/password/[token].blade.php b/resources/views/pages/auth/password/[token].blade.php new file mode 100644 index 0000000..9989b3a --- /dev/null +++ b/resources/views/pages/auth/password/[token].blade.php @@ -0,0 +1,76 @@ + 'required', 'email' => 'required|email', 'password' => 'required|min:8|same:passwordConfirmation']); +name('password.reset'); + +mount(function ($token){ + $this->email = request()->query('email', ''); + $this->token = $token; +}); + +$resetPassword = function(){ + $this->validate(); + + $response = Password::broker()->reset( + [ + 'token' => $this->token, + 'email' => $this->email, + 'password' => $this->password + ], + function ($user, $password) { + $user->password = Hash::make($password); + + $user->setRememberToken(Str::random(60)); + + $user->save(); + + event(new PasswordReset($user)); + + Auth::guard()->login($user); + } + ); + + if ($response == Password::PASSWORD_RESET) { + session()->flash(trans($response)); + + return redirect('/'); + } + + $this->addError('email', trans($response)); +} + +?> + + +
+ +
+ + + +

Reset password

+
+
+
+ @volt('auth.password.token') +
+ + + + Reset password + + @endvolt +
+
+
+
diff --git a/resources/views/pages/auth/password/confirm.blade.php b/resources/views/pages/auth/password/confirm.blade.php new file mode 100644 index 0000000..6d0139b --- /dev/null +++ b/resources/views/pages/auth/password/confirm.blade.php @@ -0,0 +1,50 @@ + '']); + rules(['password' => 'required|current_password']); + name('password.confirm'); + + $confirm = function(){ + $this->validate(); + + session()->put('auth.password_confirmed_at', time()); + + return redirect()->intended('/'); + }; +?> + + +
+ +
+ + + + +

+ Confirm your password +

+

+ Please confirm your password before continuing +

+
+ +
+
+ @volt('auth.password.confirm') +
+ +
+ Forgot your password? +
+ Confirm password + + @endvolt +
+
+
+ +
\ No newline at end of file diff --git a/resources/views/pages/auth/password/reset.blade.php b/resources/views/pages/auth/password/reset.blade.php new file mode 100644 index 0000000..b9d08b9 --- /dev/null +++ b/resources/views/pages/auth/password/reset.blade.php @@ -0,0 +1,78 @@ + null, 'emailSentMessage' => false]); +rules(['email' => 'required|email']); +name('password.request'); + + + +$sendResetPasswordLink = function(){ + $this->validate(); + + $response = Password::broker()->sendResetLink(['email' => $this->email]); + + if ($response == Password::RESET_LINK_SENT) { + $this->emailSentMessage = trans($response); + + return; + } + + $this->addError('email', trans($response)); +} + +?> + + + +
+ +
+ + + + +

+ Reset password +

+
+ Or + return to login +
+
+ + @volt('auth.password.reset') +
+
+ @if ($emailSentMessage) +
+
+
+ + + +
+ +
+

+ {{ $emailSentMessage }} +

+
+
+
+ @else +
+ + Send password reset link + + @endif +
+
+ @endvolt + +
+ +
\ No newline at end of file diff --git a/resources/views/pages/auth/register.blade.php b/resources/views/pages/auth/register.blade.php new file mode 100644 index 0000000..ff10fca --- /dev/null +++ b/resources/views/pages/auth/register.blade.php @@ -0,0 +1,65 @@ + '', 'email' => '', 'password' => '', 'passwordConfirmation' => '']); +rules(['name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|min:8|same:passwordConfirmation']); +name('register'); + +$register = function(){ + $this->validate(); + + $user = User::create([ + 'email' => $this->email, + 'name' => $this->name, + 'password' => Hash::make($this->password), + ]); + + event(new Registered($user)); + + Auth::login($user, true); + + return redirect()->intended('/'); +} + +?> + + + +
+ +
+ + + +

Create a new account

+
+ Or + sign in to your account +
+
+ +
+
+ @volt('auth.register') +
+ + + + + Register + + @endvolt +
+
+ +
+ +
diff --git a/resources/views/pages/auth/verify.blade.php b/resources/views/pages/auth/verify.blade.php new file mode 100644 index 0000000..28830cc --- /dev/null +++ b/resources/views/pages/auth/verify.blade.php @@ -0,0 +1,73 @@ +user(); + if ($user->hasVerifiedEmail()) { + redirect('/'); + } + + $user->sendEmailVerificationNotification(); + + event(new Verified($user)); + + $this->dispatch('resent'); + session()->flash('resent'); + } + +?> + + + +
+ +
+ + + + +

+ Verify your email address +

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

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

+
+
+ @endvolt + +
+
+ +
diff --git a/src/Auth.php b/src/Auth.php new file mode 100644 index 0000000..0d2d3a9 --- /dev/null +++ b/src/Auth.php @@ -0,0 +1,8 @@ +loadTranslationsFrom(__DIR__.'/../resources/lang', 'auth'); + $this->loadViewsFrom(__DIR__.'/../resources/views', 'auth'); + // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + // $this->loadRoutesFrom(__DIR__.'/routes.php'); + + $this->registerAuthFolioDirectory(); + + if ($this->app->runningInConsole()) { + $this->publishes([ + __DIR__.'/../config/config.php' => config_path('devdojoauth.php'), + ], 'config'); + + // Publishing the views. + /*$this->publishes([ + __DIR__.'/../resources/views' => resource_path('views/vendor/auth'), + ], 'views');*/ + + // Publishing assets. + $this->publishes([ + __DIR__.'/../public' => public_path('auth'), + ], 'auth'); + + // Publishing the translation files. + /*$this->publishes([ + __DIR__.'/../resources/lang' => resource_path('lang/vendor/auth'), + ], 'lang');*/ + + // Registering package commands. + // $this->commands([]); + } + + } + + private function registerAuthFolioDirectory(){ + $pagesDirectory = __DIR__ . '/../resources/views/pages'; + if (File::exists($pagesDirectory)) { + Folio::path($pagesDirectory)->middleware([ + '*' => [ + // + ], + ]); + } + } + + /** + * Register the application services. + */ + public function register() + { + // Automatically apply the package configuration + $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'auth'); + + // Register the main class to use with the facade + $this->app->singleton('devdojoauth', function () { + return new DevDojoAuth; + }); + } +} diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..165fd08 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,13 @@ +import defaultTheme from 'tailwindcss/defaultTheme'; +import forms from '@tailwindcss/forms'; + +/** @type {import('tailwindcss').Config} */ +export default { + content: [ + 'resources/views/**/*.blade.php' + ], + + theme: {}, + + plugins: [forms], +}; diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..3c7c530 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,35 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + plugins: [ + laravel({ + input: [ + 'resources/css/auth.css', + 'resources/js/auth.js', + ], + refresh: true, + }), + ], + build: { + rollupOptions: { + minify: false, + input: { + // Include both CSS and JS files as separate entry points + 'scripts': 'resources/js/auth.js', + 'styles': 'resources/css/auth.css', + }, + output: { + entryFileNames: `assets/[name].js`, + assetFileNames: ({ name }) => { + if (name.endsWith('.css')) return 'assets/[name].css'; + return 'assets/[name].[ext]'; + }, + // We can omit chunkFileNames if we are not expecting any chunks, but it's good to specify just in case + chunkFileNames: 'assets/[name].js', + } + }, + // Optionally disable code splitting if it's not desired + manualChunks: () => 'all-in-one', + } +});