From e54ce09cf52390012cbe18da75e82c2f7f725b8e Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 13:44:35 -0400 Subject: [PATCH 01/13] Adding updates to allow the socialite user to use a custom model --- src/Http/Controllers/SocialController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Http/Controllers/SocialController.php b/src/Http/Controllers/SocialController.php index 2c699f7..0050bf5 100644 --- a/src/Http/Controllers/SocialController.php +++ b/src/Http/Controllers/SocialController.php @@ -4,7 +4,6 @@ use Devdojo\Auth\Models\SocialProvider; use Devdojo\Auth\Models\SocialProviderUser; -use Devdojo\Auth\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Config; @@ -76,7 +75,7 @@ private function findOrCreateProviderUser($socialiteUser, $driver) return $providerUser; } - $user = User::where('email', $socialiteUser->getEmail())->first(); + $user = app(config('auth.providers.users.model'))->where('email', $socialiteUser->getEmail())->first(); if ($user) { $existingProvider = $user->socialProviders()->first(); @@ -95,7 +94,7 @@ private function findOrCreateProviderUser($socialiteUser, $driver) private function createUser($socialiteUser) { - return User::create([ + return app(config('auth.providers.users.model'))->create([ 'name' => $socialiteUser->getName(), 'email' => $socialiteUser->getEmail(), 'email_verified_at' => now(), From a97153d088a889ac1a7f165cc9eb7bfdff03d14c Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 13:48:53 -0400 Subject: [PATCH 02/13] fixing json composer issue --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ed63dbd..1159034 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -102,6 +102,10 @@ jobs: run: cat composer.json working-directory: ./laravel_app + - name: Remove trailing comma from composer.json + run: sed -i '/"phpunit\/phpunit": "\^9.5",/d; s/,\(\s*\}\)/\1/' composer.json + working-directory: ./laravel_app + - name: Remove composer.lock and re-run composer install run: | rm composer.lock From d67045117516eea05d6b42a5dae13dcb7b7e2b61 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 13:51:05 -0400 Subject: [PATCH 03/13] geting tests to fire --- resources/views/pages/auth/login.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/pages/auth/login.blade.php b/resources/views/pages/auth/login.blade.php index 996d308..94e83ac 100644 --- a/resources/views/pages/auth/login.blade.php +++ b/resources/views/pages/auth/login.blade.php @@ -36,6 +36,7 @@ public $userSocialProviders = []; + public $userModel = null; public function mount(){ @@ -153,7 +154,7 @@ public function authenticate() @endif @if($showSocialProviderInfo) -
+
{{ str_replace('__social_providers_list__', implode(', ', $userSocialProviders), config('devdojo.auth.language.login.social_auth_authenticated_message')) }}
@@ -169,7 +170,7 @@ public function authenticate() @if($showPasswordField) -
+
{{ config('devdojo.auth.language.login.forget_password') }}
@endif From 364eeca7ce410af0865a1e56690ab21689dbdfae Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 13:51:16 -0400 Subject: [PATCH 04/13] geting tests to fire --- resources/views/pages/auth/login.blade.php | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/views/pages/auth/login.blade.php b/resources/views/pages/auth/login.blade.php index 94e83ac..400f9dc 100644 --- a/resources/views/pages/auth/login.blade.php +++ b/resources/views/pages/auth/login.blade.php @@ -36,7 +36,6 @@ public $userSocialProviders = []; - public $userModel = null; public function mount(){ From 361e041838ff0cd548062f76e0d02efe6614ec8f Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 13:52:46 -0400 Subject: [PATCH 05/13] Getting tests to pass --- .github/workflows/tests.yml | 81 +++++++------------------------------ 1 file changed, 15 insertions(+), 66 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1159034..8c149f5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,10 +1,10 @@ -name: Authenticaiton Tests +name: Authentication Tests on: - push: - branches: [main] - pull_request: - branches: [main] + push: + branches: [main] + pull_request: + branches: [main] jobs: test: @@ -31,8 +31,8 @@ jobs: run: composer create-project --prefer-dist laravel/laravel laravel_app --no-interaction - name: Set Working Directory - run: echo "Change directory context to Laravel app" - working-directory: ./laravel_app + run: cd laravel_app + shell: bash - name: Extract branch name shell: bash @@ -65,20 +65,13 @@ jobs: run: touch database/database.sqlite working-directory: ./laravel_app - - name: List out .env - run: cat .env - working-directory: ./laravel_app - - # Testing on a mac, this command should be: - # sed -i '' 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env - # sed -i '' 's/^DB_DATABASE=laravel/#DB_DATABASE=laravel/' .env - name: Updating values in the .env run: | sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env sed -i 's/^DB_DATABASE=laravel/#DB_DATABASE=laravel/' .env working-directory: ./laravel_app - - name: Include Doctrine DBAL Package which is used for renaming columns + - name: Include Doctrine DBAL Package run: composer require doctrine/dbal working-directory: ./laravel_app @@ -90,22 +83,13 @@ jobs: run: cat composer.json working-directory: ./laravel_app - # Testing on a mac, this command should be: - # sed -i '' '/"phpunit\/phpunit"/d' composer.json - - name: Remove PHPUnit from composer.json + - name: Remove PHPUnit from composer.json and clean up commas run: | sed -i '/"phpunit\/phpunit"/d' composer.json sed -i '/"nunomaduro\/collision": "\^8.0",/s/,$//' composer.json + sed -i 's/,\(\s*\}\)/\1/' composer.json working-directory: ./laravel_app - - name: Show contents of composer.json after removing PHPUnit - run: cat composer.json - working-directory: ./laravel_app - - - name: Remove trailing comma from composer.json - run: sed -i '/"phpunit\/phpunit": "\^9.5",/d; s/,\(\s*\}\)/\1/' composer.json - working-directory: ./laravel_app - - name: Remove composer.lock and re-run composer install run: | rm composer.lock @@ -121,25 +105,11 @@ jobs: composer require protonemedia/laravel-dusk-fakes:^1.6 --dev --with-all-dependencies working-directory: ./laravel_app - - name: Upgrade Chrome Driver - run: php artisan dusk:chrome-driver --detect - working-directory: ./laravel_app - - - name: Start Chrome Driver - run: ./vendor/laravel/dusk/bin/chromedriver-linux & - working-directory: ./laravel_app - - - name: Check Chrome & ChromeDriver Versions + - name: Start Chrome Driver and PHP Server run: | - google-chrome --version - chromedriver --version - - - name: Clear all view caches - run: php artisan view:clear - working-directory: ./laravel_app - - - name: Run Artisan Serve - run: php artisan serve --no-reload & + php artisan dusk:chrome-driver --detect & + ./vendor/laravel/dusk/bin/chromedriver-linux & + php artisan serve --no-reload & working-directory: ./laravel_app - name: Run Tests @@ -151,25 +121,4 @@ jobs: APP_URL: http://127.0.0.1:8000 APP_ENV: testing run: php artisan dusk -vvv - working-directory: ./laravel_app - - - name: Upload Screenshots - if: failure() - uses: actions/upload-artifact@v3 - with: - name: screenshots - path: tests/Browser/screenshots - - name: Upload Console Logs - if: failure() - uses: actions/upload-artifact@v3 - with: - name: console - path: tests/Browser/console - - - name: Move the PHP config file to the root directory - run: cp vendor/devdojo/auth/phpstan.neon phpstan.neon - working-directory: ./laravel_app - - - name: Run PHPStan for DevDojo Auth - run: ./vendor/bin/phpstan analyse --memory-limit=1G vendor/devdojo/auth/src - working-directory: ./laravel_app + working-directory: ./laravel_app \ No newline at end of file From 8f11cb92f61555bc842ecaab79b354f1c9867bca Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 13:59:43 -0400 Subject: [PATCH 06/13] cleaning up the tests --- .github/workflows/tests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c149f5..23d9aef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -79,17 +79,17 @@ jobs: run: php artisan migrate working-directory: ./laravel_app - - name: Show contents of composer.json before removing PHPUnit - run: cat composer.json - working-directory: ./laravel_app - - - name: Remove PHPUnit from composer.json and clean up commas + - name: Clean up composer.json - Remove PHPUnit & trailing commas run: | sed -i '/"phpunit\/phpunit"/d' composer.json sed -i '/"nunomaduro\/collision": "\^8.0",/s/,$//' composer.json sed -i 's/,\(\s*\}\)/\1/' composer.json working-directory: ./laravel_app + - name: Validate composer.json format + run: php -r "json_decode(file_get_contents('composer.json')) ?: exit(1);" + working-directory: ./laravel_app + - name: Remove composer.lock and re-run composer install run: | rm composer.lock From 33182dc17c01caaf6d289b34bc783e5cf0b11284 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 14:04:35 -0400 Subject: [PATCH 07/13] cleaning up the tests --- resources/views/pages/auth/setup/index.blade.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/views/pages/auth/setup/index.blade.php b/resources/views/pages/auth/setup/index.blade.php index b349c40..bea9fd8 100644 --- a/resources/views/pages/auth/setup/index.blade.php +++ b/resources/views/pages/auth/setup/index.blade.php @@ -17,11 +17,12 @@ @volt('auth.setup') -
+
@if(!file_exists(base_path('config/devdojo/auth/settings.php'))) @endif
+

Authentication Setup

Welcome to your authentication setup. Below you will find sections to help you configure and customize the auth in your application.

@@ -31,8 +32,8 @@
-
- +
+ @include('auth::includes.setup.icons.preview')
@@ -40,7 +41,7 @@

Click here to see what your authentication pages look like.

-
+
To learn more about this authentication package, be sure to visit the documentation or view the project on Github.
From 96843bbee458a554a3a2edf105bbd2ce7fa20bfe Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 14:04:47 -0400 Subject: [PATCH 08/13] cleaning up the tests --- resources/views/pages/auth/setup/index.blade.php | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/views/pages/auth/setup/index.blade.php b/resources/views/pages/auth/setup/index.blade.php index bea9fd8..f226a5e 100644 --- a/resources/views/pages/auth/setup/index.blade.php +++ b/resources/views/pages/auth/setup/index.blade.php @@ -22,7 +22,6 @@ @endif
-

Authentication Setup

Welcome to your authentication setup. Below you will find sections to help you configure and customize the auth in your application.

From 24a057d7a60e315b8c189efcdfb0b183d29db075 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 14:07:58 -0400 Subject: [PATCH 09/13] fixing tests --- .github/workflows/tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 23d9aef..fb7c90c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,10 +30,6 @@ jobs: - name: Setup Laravel Application run: composer create-project --prefer-dist laravel/laravel laravel_app --no-interaction - - name: Set Working Directory - run: cd laravel_app - shell: bash - - name: Extract branch name shell: bash run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV From d8cdb8f96bce89a47342c7fe324c35d7645f696e Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 14:11:15 -0400 Subject: [PATCH 10/13] getting fixes to work --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fb7c90c..d33110b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,7 +83,7 @@ jobs: working-directory: ./laravel_app - name: Validate composer.json format - run: php -r "json_decode(file_get_contents('composer.json')) ?: exit(1);" + run: php -r 'json_decode(file_get_contents("composer.json")) ?: exit(1);' working-directory: ./laravel_app - name: Remove composer.lock and re-run composer install From 2b2685fad1eaaa39fc3079dd79a5aca9305c12b0 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 14:16:44 -0400 Subject: [PATCH 11/13] getting fixes to work --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d33110b..5749996 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,7 +83,8 @@ jobs: working-directory: ./laravel_app - name: Validate composer.json format - run: php -r 'json_decode(file_get_contents("composer.json")) ?: exit(1);' + run: | + php -r 'json_decode(file_get_contents("composer.json")) ?: exit(1);' working-directory: ./laravel_app - name: Remove composer.lock and re-run composer install From c4cb28cc0178826ea2469295d8c7e22f0b623fdb Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 14:25:04 -0400 Subject: [PATCH 12/13] getting fixes to work --- .github/workflows/tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5749996..270f380 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -82,9 +82,13 @@ jobs: sed -i 's/,\(\s*\}\)/\1/' composer.json working-directory: ./laravel_app + - name: Show composer.json contents + run: cat composer.json + working-directory: ./laravel_app + - name: Validate composer.json format run: | - php -r 'json_decode(file_get_contents("composer.json")) ?: exit(1);' + php -r 'if (!json_decode(file_get_contents("composer.json"))) { echo "JSON error: " . json_last_error_msg(); exit(1); }' working-directory: ./laravel_app - name: Remove composer.lock and re-run composer install From ad8d9c89732fa5a81c2297cdf06c2f27896a0537 Mon Sep 17 00:00:00 2001 From: Tony Lea Date: Fri, 25 Oct 2024 14:39:06 -0400 Subject: [PATCH 13/13] getting fixes to work --- .github/workflows/tests.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 270f380..ba1065f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,7 +36,7 @@ jobs: id: extract_branch - name: Install DevDojo Auth from current branch - run: composer require devdojo/auth:dev-${{ env.branch }} --with-all-dependencies + run: "composer require devdojo/auth:dev-${{ env.branch }} --with-all-dependencies" working-directory: ./laravel_app - name: Publish the DevDojo Auth Assets @@ -78,12 +78,9 @@ jobs: - name: Clean up composer.json - Remove PHPUnit & trailing commas run: | sed -i '/"phpunit\/phpunit"/d' composer.json - sed -i '/"nunomaduro\/collision": "\^8.0",/s/,$//' composer.json - sed -i 's/,\(\s*\}\)/\1/' composer.json - working-directory: ./laravel_app - - - name: Show composer.json contents - run: cat composer.json + sed -i '/"nunomaduro\/collision": "\^8.1",/s/,$//' composer.json + # Remove any trailing commas before a closing bracket in require-dev + sed -i 's/,\s*}/}/' composer.json working-directory: ./laravel_app - name: Validate composer.json format