Skip to content

Commit

Permalink
Applied fixes from StyleCI (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
srmklive authored Sep 19, 2016
1 parent 29cb651 commit ad10b3f
Show file tree
Hide file tree
Showing 33 changed files with 193 additions and 179 deletions.
3 changes: 2 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
12 changes: 7 additions & 5 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace App\Exceptions;

use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\HttpException;

class Handler extends ExceptionHandler
{
Expand All @@ -28,7 +28,8 @@ class Handler extends ExceptionHandler
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @param \Exception $e
*
* @return void
*/
public function report(Exception $e)
Expand All @@ -39,8 +40,9 @@ public function report(Exception $e)
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @param \Illuminate\Http\Request $request
* @param \Exception $e
*
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
Expand Down
48 changes: 27 additions & 21 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\User;
use Auth;
use Authy;
use FlashAlert;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Http\Request;
use Validator;

class AuthController extends Controller
{
Expand Down Expand Up @@ -48,8 +48,9 @@ public function __construct()
/**
* Send the post-authentication response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
*
* @return \Illuminate\Http\Response
*/
protected function authenticated(Request $request, Authenticatable $user)
Expand All @@ -66,7 +67,8 @@ protected function authenticated(Request $request, Authenticatable $user)
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
Expand All @@ -87,7 +89,7 @@ public function register(Request $request)
}

/**
* Show two-factor authentication page
* Show two-factor authentication page.
*
* @return \Illuminate\Http\Response|\Illuminate\View\View
*/
Expand All @@ -99,21 +101,22 @@ public function getToken()
/**
* Verify the two-factor authentication token.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function postToken(Request $request)
{
$this->validate($request, ['token' => 'required']);
if (! session('authy:auth:id')) {
if (!session('authy:auth:id')) {
return redirect(url('login'));
}

$guard = config('auth.defaults.guard');
$provider = config('auth.guards.' . $guard . '.provider');
$model = config('auth.providers.' . $provider . '.model');
$provider = config('auth.guards.'.$guard.'.provider');
$model = config('auth.providers.'.$provider.'.model');

$user = (new $model)->findOrFail(
$user = (new $model())->findOrFail(
$request->session()->pull('authy:auth:id')
);

Expand All @@ -133,8 +136,9 @@ public function postToken(Request $request)
/**
* Generate a redirect response to the two-factor token screen.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
*
* @return \Illuminate\Http\Response
*/
protected function logoutAndRedirectToTokenScreen(Request $request, Authenticatable $user)
Expand Down Expand Up @@ -163,29 +167,31 @@ public function logout()
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @param array $data
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @param array $data
*
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
Expand Down
21 changes: 12 additions & 9 deletions app/Http/Controllers/Auth/TwoFactorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace App\Http\Controllers\Auth;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;
use Authy;
use Exception;
use FlashAlert;
use Illuminate\Http\Request;
use Validator;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class TwoFactorController extends Controller
{
Expand All @@ -19,14 +18,15 @@ public function __construct()
}

/**
* Enable two-factor authentication
* Enable two-factor authentication.
*
* @param \Illuminate\Http\Request $request
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|null
*/
public function postEnable(Request $request)
{
if (! is_null($response = $this->validateEnablingTwoFactorAuth($request))) {
if (!is_null($response = $this->validateEnablingTwoFactorAuth($request))) {
return redirect(url('home'))->withErrors($response);
}

Expand All @@ -40,8 +40,9 @@ public function postEnable(Request $request)

// Check if the user wants to receive token via SMS
$sms = false;
if (!empty($input['sms']))
if (!empty($input['sms'])) {
$sms = true;
}

try {
Authy::getProvider()->register($user, $sms);
Expand All @@ -61,7 +62,8 @@ public function postEnable(Request $request)
/**
* Validate an incoming request to enable two-factor authentication.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response|null
*/
protected function validateEnablingTwoFactorAuth(Request $request)
Expand All @@ -73,7 +75,7 @@ protected function validateEnablingTwoFactorAuth(Request $request)
}

$validator = Validator::make($input, [
'country-code' => 'required|numeric|integer',
'country-code' => 'required|numeric|integer',
'authy-cellphone' => 'required|numeric',
]);

Expand All @@ -83,9 +85,10 @@ protected function validateEnablingTwoFactorAuth(Request $request)
}

/**
* Disable two-factor authentication
* Disable two-factor authentication.
*
* @param \Illuminate\Http\Request $request
*
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|nul
*/
public function postDisable(Request $request)
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use App\Http\Requests;
use Auth;
use Authy;
use Illuminate\Http\Request;
Expand All @@ -23,6 +22,7 @@ public function __construct()
* Show the application dashboard.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ class Kernel extends HttpKernel
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}
7 changes: 4 additions & 3 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ class Authenticate
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
*
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
Expand Down
7 changes: 4 additions & 3 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ class RedirectIfAuthenticated
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
*
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
Expand Down
8 changes: 4 additions & 4 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

Route::auth();

Route::get('auth/token','Auth\AuthController@getToken');
Route::post('auth/token','Auth\AuthController@postToken');
Route::post('auth/twofactor/enable','Auth\TwoFactorController@postEnable');
Route::post('auth/twofactor/disable','Auth\TwoFactorController@postDisable');
Route::get('auth/token', 'Auth\AuthController@getToken');
Route::post('auth/token', 'Auth\AuthController@postToken');
Route::post('auth/twofactor/enable', 'Auth\TwoFactorController@postEnable');
Route::post('auth/twofactor/disable', 'Auth\TwoFactorController@postDisable');

Route::get('/home', 'HomeController@index');
3 changes: 2 additions & 1 deletion app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class AuthServiceProvider extends ServiceProvider
/**
* Register any application authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
*
* @return void
*/
public function boot(GateContract $gate)
Expand Down
3 changes: 2 additions & 1 deletion app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class EventServiceProvider extends ServiceProvider
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @param \Illuminate\Contracts\Events\Dispatcher $events
*
* @return void
*/
public function boot(DispatcherContract $events)
Expand Down
Loading

0 comments on commit ad10b3f

Please sign in to comment.