Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with enums #33

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],


Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions config/laravel-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],

/*
Expand Down
4 changes: 2 additions & 2 deletions resources/views/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@

<div class="space-y-4">
@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')))
<x-auth::form.button.ahref
:href="route('auth.provider', \CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365())"
:href="route('auth.provider', \CodebarAg\LaravelAuth\Enums\ProviderEnum::MICROSOFT_OFFICE_365->value)"
class="bg-gray-500 hover:bg-gray-400"
>
<svg class="fill-white w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 278050 333334" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd"><path fill="currentColor" d="M278050 305556l-29-16V28627L178807 0 448 66971l-448 87 22 200227 60865-23821V80555l117920-28193-17 239519L122 267285l178668 65976v73l99231-27462v-316z"/></svg>
Expand Down
8 changes: 4 additions & 4 deletions src/Controllers/ProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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,
],
[
Expand Down
11 changes: 2 additions & 9 deletions src/Enums/ProviderEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
1 change: 0 additions & 1 deletion src/LaravelAuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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`');
});
}

Expand Down