From 94eb3b86f7566ddf1b2aadf0f0bf467b419067db Mon Sep 17 00:00:00 2001
From: Rhys Lees <43909932+RhysLees@users.noreply.github.com>
Date: Tue, 24 Oct 2023 14:16:57 +0200
Subject: [PATCH 1/2] WIP
---
README.md | 6 +++---
composer.json | 1 -
config/laravel-auth.php | 4 ++--
resources/views/login.blade.php | 4 ++--
src/Controllers/ProviderController.php | 8 ++++----
src/Enums/ProviderEnum.php | 11 ++---------
6 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/README.md b/README.md
index 613b089..7908663 100644
--- a/README.md
+++ b/README.md
@@ -291,12 +291,12 @@ return [
|--------------------------------------------------------------------------
| Provider Settings
|--------------------------------------------------------------------------
- | By default, all providers are enabled.
- | You may disable a provider by adding it to the disabled array.
+ | Add the providers you want to use here.
+ | e.g ProviderEnum::MICROSOFT_OFFICE_365,
|
*/
'providers' => [
- ProviderEnum::MICROSOFT_OFFICE_365(),
+ ProviderEnum::MICROSOFT_OFFICE_365,
],
diff --git a/composer.json b/composer.json
index 331b9d6..8e27c21 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,6 @@
"illuminate/contracts": "^10.0",
"laravel/socialite": "^5.8",
"socialiteproviders/microsoft": "^4.2",
- "spatie/laravel-enum": "^3.0",
"spatie/laravel-package-tools": "^1.16.1",
"spatie/laravel-flash": "^1.9",
"spatie/laravel-activitylog": "^4.7",
diff --git a/config/laravel-auth.php b/config/laravel-auth.php
index 6650bc2..f14b303 100644
--- a/config/laravel-auth.php
+++ b/config/laravel-auth.php
@@ -86,11 +86,11 @@
| Provider Settings
|--------------------------------------------------------------------------
| Add the providers you want to use here.
- | e.g ProviderEnum::MICROSOFT_OFFICE_365(),
+ | e.g ProviderEnum::MICROSOFT_OFFICE_365,
|
*/
'providers' => [
- ProviderEnum::MICROSOFT_OFFICE_365(),
+ ProviderEnum::MICROSOFT_OFFICE_365,
],
/*
diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php
index 3e64540..051fa04 100644
--- a/resources/views/login.blade.php
+++ b/resources/views/login.blade.php
@@ -51,9 +51,9 @@
@if(config('laravel-auth.features.sso'))
- @if(in_array(\CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365(), config('laravel-auth.providers')))
+ @if(in_array(\CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365, config('laravel-auth.providers')))
diff --git a/src/Controllers/ProviderController.php b/src/Controllers/ProviderController.php
index b103eb6..16e55be 100644
--- a/src/Controllers/ProviderController.php
+++ b/src/Controllers/ProviderController.php
@@ -35,20 +35,20 @@ public function serviceRedirect($service)
protected function allowed($provider)
{
- if (! in_array($provider->value, config('laravel-auth.providers'))) {
+ if (! in_array($provider, config('laravel-auth.providers'))) {
abort(503);
}
}
public function microsoft()
{
- return Socialite::driver(ProviderEnum::MICROSOFT_OFFICE_365()->value)->redirect();
+ return Socialite::driver(ProviderEnum::MICROSOFT_OFFICE_365->value)->redirect();
}
public function microsoftRedirect()
{
try {
- $socialiteUser = Socialite::driver(ProviderEnum::MICROSOFT_OFFICE_365()->value)->user();
+ $socialiteUser = Socialite::driver(ProviderEnum::MICROSOFT_OFFICE_365->value)->user();
} catch (\Exception $e) {
flash(__('Authentication Error.'), 'warning');
@@ -57,7 +57,7 @@ public function microsoftRedirect()
$provider = AuthProvider::updateOrCreate(
[
- 'provider' => ProviderEnum::MICROSOFT_OFFICE_365()->value,
+ 'provider' => ProviderEnum::MICROSOFT_OFFICE_365->value,
'provider_id' => $socialiteUser->id,
],
[
diff --git a/src/Enums/ProviderEnum.php b/src/Enums/ProviderEnum.php
index 97ba1ab..70401b8 100644
--- a/src/Enums/ProviderEnum.php
+++ b/src/Enums/ProviderEnum.php
@@ -2,17 +2,10 @@
namespace CodebarAg\LaravelAuth\Enums;
-use Spatie\Enum\Laravel\Enum;
-
/**
* @method static self MICROSOFT_OFFICE_365()
*/
-class ProviderEnum extends Enum
+enum ProviderEnum: string
{
- protected static function values(): array
- {
- return [
- 'MICROSOFT_OFFICE_365' => 'microsoft',
- ];
- }
+ case MICROSOFT_OFFICE_365 = 'microsoft';
}
From 81afc770aca0a6467c0d884e277ccec1a7af6027 Mon Sep 17 00:00:00 2001
From: Rhys Lees <43909932+RhysLees@users.noreply.github.com>
Date: Tue, 24 Oct 2023 14:54:22 +0200
Subject: [PATCH 2/2] WIP
---
src/LaravelAuthServiceProvider.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/LaravelAuthServiceProvider.php b/src/LaravelAuthServiceProvider.php
index b402325..737b7f2 100644
--- a/src/LaravelAuthServiceProvider.php
+++ b/src/LaravelAuthServiceProvider.php
@@ -45,7 +45,6 @@ public function configurePackage(Package $package): void
->publishAssets()
->publishMigrations()
->askToRunMigrations();
- // ->info('If you want to install the tests, run `php artisan auth:install-tests`');
});
}