Skip to content

Commit

Permalink
Merge pull request #4 from konsulting/analysis-zDWWlb
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
Keoghan authored Mar 21, 2017
2 parents 559312f + 6718cef commit 553d3ef
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 32 deletions.
18 changes: 9 additions & 9 deletions config/butler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,50 @@

return
[
/**
/*
* The UserProvider - responsible for finding and creating users when required.
*/
'user_provider' => \Konsulting\Butler\EloquentUserProvider::class,

/**
/*
* The user class for mapping identities to.
*/
'user_class' => \App\User::class,

/**
/*
* A list of providers to use. These map to Socialite Drivers.
*/
'providers' => [
// 'google' => ['name' => 'Google', 'icon' => 'fa fa-google', 'class' => 'btn-google'],
// 'facebook' => ['name' => 'Facebook', 'icon' => 'fa fa-facebook', 'class' => 'btn-facebook'],
],

/**
/*
* Can Butler create users if social login is requested for non-exiting user?
*/
'can_create_users' => false,

/**
/*
* Should we ask the user to confirm the identity if it is their first one and they just created the account?
*/
'confirm_identity_for_new_user' => true,

/**
/*
* The class of the notification to send when adding a social identity
*/
'confirm_identity_notification' => \Konsulting\Butler\Notifications\ConfirmSocialIdentity::class,

/**
/*
* Should we log the user in straight after confirmation?
*/
'login_immediately_after_confirm' => false,

/**
/*
* The application routes for us to use when redirecting the user after actions
*/
'route_map' => [
'login' => 'login',
'authenticated' => 'home',
'profile' => 'profile',
]
],
];
1 change: 0 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
Route::get('/auth/provider/{provider}', 'AuthController@redirect')->name('butler.redirect');
Route::get('/auth/provider/{provider}/callback', 'AuthController@callback')->name('butler.callback');
});

6 changes: 3 additions & 3 deletions src/Butler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function providers()
}

/**
* Return a single provider's details
* Return a single provider's details.
*
* @param $provider
*
Expand Down Expand Up @@ -127,7 +127,7 @@ public function authenticate($provider, Identity $identity)
}

/**
* Get the Guard instance
* Get the Guard instance.
*
* @return mixed
*/
Expand All @@ -139,7 +139,7 @@ protected function guard()
/**
* Register an Identity with a user. We'll use the authenticated user,
* or if we can't find an appropriate user, create one if allowed.
* Otherwise, we will fail through a graceful Exception :)
* Otherwise, we will fail through a graceful Exception :).
*
* @param $provider
* @param \Laravel\Socialite\Contracts\User $identity
Expand Down
6 changes: 3 additions & 3 deletions src/ButlerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ class ButlerServiceProvider extends ServiceProvider
{
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../views', 'butler');
$this->loadViewsFrom(__DIR__ . '/../views', 'butler');

$this->publishes([
__DIR__ . '/../config/butler.php' => config_path('butler.php'),
], 'config');

$this->publishes([
__DIR__.'/../views' => resource_path('views/vendor/butler'),
__DIR__ . '/../views' => resource_path('views/vendor/butler'),
], 'views');

$this->loadMigrationsFrom(__DIR__.'/../migrations');
$this->loadMigrationsFrom(__DIR__ . '/../migrations');
}

public function register()
Expand Down
8 changes: 4 additions & 4 deletions src/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Konsulting\Butler\Controllers;

use Butler;
use GuzzleHttp\Exception\ClientException;
use Konsulting\Butler\Exceptions\NoUser;
use Konsulting\Butler\Exceptions\UnknownProvider;
use GuzzleHttp\Exception\ClientException;
use Laravel\Socialite\Two\InvalidStateException;
use Konsulting\Butler\Exceptions\UnableToConfirm;
use Konsulting\Butler\Exceptions\UnknownProvider;
use Illuminate\Routing\Controller as BaseController;
use Laravel\Socialite\Contracts\Factory as SocialiteManager;
use Konsulting\Butler\Exceptions\UserAlreadyHasSocialIdentity;
Expand Down Expand Up @@ -43,6 +43,7 @@ public function redirect($provider)
->with('status.content', 'Unknown Provider.')
->with('status.type', 'warning');
}

return $this->socialite->driver($provider)->redirect();
}

Expand Down Expand Up @@ -110,7 +111,7 @@ public function callback($provider)
}

/**
* Confirm a Social Identity by matching the unique code
* Confirm a Social Identity by matching the unique code.
*
* @param $token
*
Expand All @@ -124,7 +125,6 @@ public function confirm($token)
if (config('butler.login_immediately_after_confirm', false)) {
$this->guard()->login($socialIdentity->user);
}

} catch (UnableToConfirm $e) {
return redirect()->route(Butler::routeName('login'))
->with('status.content', 'Unable to confirm identity usage.')
Expand Down
5 changes: 3 additions & 2 deletions src/EloquentUserProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Konsulting\Butler;

use Laravel\Socialite\Contracts\User as Identity;
Expand Down Expand Up @@ -28,7 +29,7 @@ public function __construct($model)
*/
public function canCreateUsers($flag = true)
{
$this->canCreateUsers = (boolean) $flag;
$this->canCreateUsers = (bool) $flag;

return $this;
}
Expand Down Expand Up @@ -73,7 +74,7 @@ public function createFromOauthIdentity(Identity $oauthId)
}

/**
* Confirm or deny whether we created a user
* Confirm or deny whether we created a user.
*
* @param $user
*
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/ConfirmSocialIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Konsulting\Butler\Notifications;

use Illuminate\Bus\Queueable;
use Konsulting\Butler\SocialIdentity;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Konsulting\Butler\SocialIdentity;

class ConfirmSocialIdentity extends Notification implements ShouldQueue
{
Expand Down
4 changes: 2 additions & 2 deletions src/SocialIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function createFromOauthIdentity($provider, $user, Identity $ident
}

/**
* Check if we are byond the confirmation deadline
* Check if we are byond the confirmation deadline.
*/
public function pastConfirmationDeadline()
{
Expand Down Expand Up @@ -159,7 +159,7 @@ public static function retrievePossibleByOauthIdentity($provider, Identity $iden
{
return static::where('provider', $provider)
->where('reference', $identity->getId())
->where(function($query) {
->where(function ($query) {
$now = Carbon::now();

$query->where('confirmed_at', '<=', $now)
Expand Down
1 change: 0 additions & 1 deletion tests/AuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Konsulting\Butler;

use Route;
use Butler;
use Notification;
use Konsulting\Butler\Fake\User;
Expand Down
4 changes: 2 additions & 2 deletions tests/BasicButlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Konsulting\Butler;

use Butler;
use Konsulting\Butler\Fake\User;
use Konsulting\Butler\Exceptions\NoUser;
use Konsulting\Butler\Exceptions\SocialIdentityAlreadyAssociated;
use Konsulting\Butler\Exceptions\UnknownProvider;
use Konsulting\Butler\Fake\User;
use Konsulting\Butler\Exceptions\SocialIdentityAlreadyAssociated;

class BasicButlerTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fakes/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;

class User extends Model implements AuthenticatableContract
{
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Konsulting\Butler;

use Route;
use Schema;
use Butler;
use Schema;
use Konsulting\Butler\Fake\User;
use Konsulting\Butler\Fake\Identity;
use Konsulting\Butler\Fake\Socialite;
Expand All @@ -14,7 +14,7 @@
abstract class TestCase extends \Orchestra\Testbench\BrowserKit\TestCase
{
/**
* Set up ServiceProviders
* Set up ServiceProviders.
*
* @param \Illuminate\Foundation\Application $app
*
Expand All @@ -28,7 +28,7 @@ protected function getPackageProviders($app)
}

/**
* Set up Facades
* Set up Facades.
*
* @param \Illuminate\Foundation\Application $app
*
Expand Down

0 comments on commit 553d3ef

Please sign in to comment.