Skip to content

Commit

Permalink
Merge pull request #78 from renoki-co/feature/refactoring
Browse files Browse the repository at this point in the history
[refactor] Refactored to next major
  • Loading branch information
rennokki authored Feb 1, 2023
2 parents 60d1da3 + 1e492db commit 6b5e278
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 23 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ jobs:
- '8.0'
- '8.1'
laravel:
- '8.*'
- '9.*'
prefer:
- 'prefer-lowest'
- 'prefer-stable'
include:
- laravel: '8.*'
testbench: '6.*'
- laravel: '9.*'
testbench: '7.*'

Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
}
],
"require": {
"illuminate/database": "^8.83|^9.0.1",
"illuminate/support": "^8.83|^9.0.1",
"illuminate/database": "^9.0.1",
"illuminate/support": "^9.0.1",
"laravel/socialite": "^5.3"
},
"autoload": {
Expand All @@ -44,16 +44,17 @@
"require-dev": {
"laravel/legacy-factories": "^1.3",
"mockery/mockery": "^1.5",
"orchestra/database": "^6.28|^7.0",
"orchestra/testbench": "^6.28|^7.0",
"orchestra/testbench-browser-kit": "^6.28|^7.0",
"orchestra/testbench-core": "^6.28|^7.0",
"orchestra/database": "^7.0",
"orchestra/testbench": "^7.0",
"orchestra/testbench-browser-kit": "^7.0",
"orchestra/testbench-core": "^7.0",
"phpunit/phpunit": "^9.5.21"
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"laravel": {
"providers": [
Expand Down
37 changes: 36 additions & 1 deletion config/hej.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,41 @@
|
*/

'default_authenticatable' => \App\User::class,
'default_authenticatable' => \App\Models\User::class,

/*
|--------------------------------------------------------------------------
| Redirects
|--------------------------------------------------------------------------
|
| Specify the route names to use as redirects after different actions.
| These can be also overwritten if you extend the controller class.
|
*/

'redirects' => [
'authenticated' => 'home',
'provider_rejected' => 'home',
'duplicate_email' => 'home',
'provider_already_linked' => 'home',
'provider_linked_to_another' => 'home',
'link' => 'home',
'unlink' => 'home',
],

/*
|--------------------------------------------------------------------------
| Allowed Providers
|--------------------------------------------------------------------------
|
| This will overwrite the list of allowed providers within the controller.
|
*/

'allowed_providers' => [
// 'facebook',
// 'twitter',
// 'github',
],

];
20 changes: 12 additions & 8 deletions src/Http/Controllers/SocialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SocialController extends Controller
/**
* The Socialite factory instance.
*
* @var Laravel\Socialite\Contracts\Factory
* @var \Laravel\Socialite\Contracts\Factory
*/
protected $socialite;

Expand All @@ -32,6 +32,10 @@ class SocialController extends Controller
public function __construct(Socialite $socialite)
{
$this->socialite = $socialite;

if ($allowedProviders = config('hej.allowed_providers')) {
static::$allowedSocialiteProviders = $allowedProviders;
}
}

/**
Expand Down Expand Up @@ -321,7 +325,7 @@ protected function unlinked(Request $request, $model, string $provider)
*/
protected function redirectToAfterAuthentication($model)
{
return Redirect::route('home');
return Redirect::route(config('hej.redirects.authenticated', 'home'));
}

/**
Expand All @@ -334,7 +338,7 @@ protected function redirectToAfterAuthentication($model)
*/
protected function redirectToAfterProviderIsRejected(Request $request, $provider)
{
return Redirect::route('home');
return Redirect::route(config('hej.redirects.provider_rejected', 'home'));
}

/**
Expand All @@ -350,7 +354,7 @@ protected function redirectToAfterProviderIsRejected(Request $request, $provider
*/
protected function redirectToAfterDuplicateEmail(Request $request, $provider, $providerUser)
{
return Redirect::route('home');
return Redirect::route(config('hej.redirects.duplicate_email', 'home'));
}

/**
Expand All @@ -364,7 +368,7 @@ protected function redirectToAfterDuplicateEmail(Request $request, $provider, $p
*/
protected function redirectToAfterProviderIsAlreadyLinked(Request $request, $provider, $model)
{
return Redirect::route('home');
return Redirect::route(config('hej.redirects.provider_already_linked', 'home'));
}

/**
Expand All @@ -380,7 +384,7 @@ protected function redirectToAfterProviderIsAlreadyLinked(Request $request, $pro
protected function redirectToAfterProviderAlreadyLinkedByAnotherAuthenticatable(
Request $request, $provider, $model, $providerUser
) {
return Redirect::route('home');
return Redirect::route(config('hej.redirects.provider_linked_to_another', 'home'));
}

/**
Expand All @@ -395,7 +399,7 @@ protected function redirectToAfterProviderAlreadyLinkedByAnotherAuthenticatable(
*/
protected function redirectToAfterLink(Request $request, $model, $social, $providerUser)
{
return Redirect::route('home');
return Redirect::route(config('hej.redirects.link', 'home'));
}

/**
Expand All @@ -409,6 +413,6 @@ protected function redirectToAfterLink(Request $request, $model, $social, $provi
*/
protected function redirectToAfterUnlink(Request $request, $model, string $provider)
{
return Redirect::route('home');
return Redirect::route(config('hej.redirects.unlink', 'home'));
}
}
6 changes: 1 addition & 5 deletions src/Social.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ class Social extends Model
/**
* {@inheritdoc}
*/
protected $fillable = [
'model_id', 'model_type', 'provider', 'provider_id',
'provider_nickname', 'provider_name', 'provider_email',
'provider_avatar',
];
protected $guarded = [];

/**
* Get the model that uses this Social instance.
Expand Down

0 comments on commit 6b5e278

Please sign in to comment.