diff --git a/.env.example b/.env.example index 9c9a013..6bd521c 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ -SITE_NAME=Hypothetical Template -SITE_DESC=A website template +SITE_NAME="Hypothetical Template" +SITE_DESC="A website template" APP_ENV=local APP_DEBUG=true diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0aad259..71c519d 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - \App\Console\Commands\Inspire::class, + // Commands\Inspire::class, ]; /** @@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('inspire') - ->hourly(); + // $schedule->command('inspire') + // ->hourly(); } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 2cc435b..a4ada88 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,7 +3,10 @@ namespace App\Exceptions; use Exception; +use Illuminate\Auth\Access\AuthorizationException; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Symfony\Component\HttpKernel\Exception\HttpException; +use Illuminate\Foundation\Validation\ValidationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler @@ -14,7 +17,10 @@ class Handler extends ExceptionHandler * @var array */ protected $dontReport = [ + AuthorizationException::class, HttpException::class, + ModelNotFoundException::class, + ValidationException::class, ]; /** @@ -27,7 +33,7 @@ class Handler extends ExceptionHandler */ public function report(Exception $e) { - return parent::report($e); + parent::report($e); } /** diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 4e7f7cf..417365a 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -24,9 +24,11 @@ class AuthController extends Controller use AuthenticatesAndRegistersUsers, ThrottlesLogins; /** - * Page the user is redirected to after successfully registering + * Where to redirect users after login / registration. + * + * @var string */ - protected $redirectPath = '/dashboard'; + protected $redirectTo = '/dashboard'; /** * Create a new authentication controller instance. @@ -35,7 +37,7 @@ class AuthController extends Controller */ public function __construct() { - $this->middleware('guest', ['except' => 'getLogout']); + $this->middleware('guest', ['except' => 'logout']); } /** diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 9be752a..7371801 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -5,8 +5,9 @@ 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; -abstract class Controller extends BaseController +class Controller extends BaseController { use DispatchesJobs, ValidatesRequests; } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index ceea60a..f0d8083 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -9,25 +9,44 @@ class Kernel extends HttpKernel /** * The application's global HTTP middleware stack. * + * These middleware are run during every request to your application. + * * @var array */ protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, - \App\Http\Middleware\EncryptCookies::class, - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, - \Illuminate\Session\Middleware\StartSession::class, - \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \App\Http\Middleware\VerifyCsrfToken::class, + ]; + + /** + * The application's route middleware groups. + * + * @var array + */ + protected $middlewareGroups = [ + 'web' => [ + \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + ], + + 'api' => [ + 'throttle:60,1', + ], ]; /** * The application's route middleware. * + * These middleware may be assigned to groups or used individually. + * * @var array */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, ]; } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 4fbafec..faaeb04 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -3,38 +3,21 @@ namespace App\Http\Middleware; use Closure; -use Illuminate\Contracts\Auth\Guard; +use Illuminate\Support\Facades\Auth; class Authenticate { - /** - * The Guard implementation. - * - * @var Guard - */ - protected $auth; - - /** - * Create a new filter instance. - * - * @param Guard $auth - * @return void - */ - public function __construct(Guard $auth) - { - $this->auth = $auth; - } - /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next + * @param string|null $guard * @return mixed */ - public function handle($request, Closure $next) + public function handle($request, Closure $next, $guard = null) { - if ($this->auth->guest()) { + if (Auth::guard($guard)->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 495b629..e27860e 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -3,39 +3,22 @@ namespace App\Http\Middleware; use Closure; -use Illuminate\Contracts\Auth\Guard; +use Illuminate\Support\Facades\Auth; class RedirectIfAuthenticated { - /** - * The Guard implementation. - * - * @var Guard - */ - protected $auth; - - /** - * Create a new filter instance. - * - * @param Guard $auth - * @return void - */ - public function __construct(Guard $auth) - { - $this->auth = $auth; - } - /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next + * @param string|null $guard * @return mixed */ - public function handle($request, Closure $next) + public function handle($request, Closure $next, $guard = null) { - if ($this->auth->check()) { - return redirect('/home'); + if (Auth::guard($guard)->check()) { + return redirect('/'); } return $next($request); diff --git a/app/Http/routes.php b/app/Http/routes.php index 3ba109d..ac15a50 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -1,32 +1,34 @@ ['web']], function () { + /* + |-------------------------------------------------------------------------- + | Public Routes + |-------------------------------------------------------------------------- + */ -Route::get('/', function () { - return view('website.home'); + Route::get('/', function () { + return view('website.home'); + }); + + Route::get('/contact', function() { + return view('website.contact'); + }); + + Route::post('/contact-submit', 'ContactController@postContactSubmit'); + + /* + |-------------------------------------------------------------------------- + | Content Management Routes + |-------------------------------------------------------------------------- + */ + + // Authentication + Route::get('auth/login', 'Auth\AuthController@getLogin'); + Route::post('auth/login', 'Auth\AuthController@postLogin'); + Route::get('auth/logout', 'Auth\AuthController@getLogout'); + + // Registration + Route::get('auth/register', 'Auth\AuthController@getRegister'); + Route::post('auth/register', 'Auth\AuthController@postRegister'); }); - -Route::get('/contact', function() { - return view('website.contact'); -}); - -Route::post('/contact-submit', 'ContactController@postContactSubmit'); - -/* -|-------------------------------------------------------------------------- -| Content Management Routes -|-------------------------------------------------------------------------- -*/ - -// Authentication -Route::get('auth/login', 'Auth\AuthController@getLogin'); -Route::post('auth/login', 'Auth\AuthController@postLogin'); -Route::get('auth/logout', 'Auth\AuthController@getLogout'); - -// Registration -Route::get('auth/register', 'Auth\AuthController@getRegister'); -Route::post('auth/register', 'Auth\AuthController@postRegister'); diff --git a/app/User.php b/app/User.php index 86eabed..ef6fe91 100644 --- a/app/User.php +++ b/app/User.php @@ -2,34 +2,25 @@ namespace App; -use Illuminate\Auth\Authenticatable; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Auth\Passwords\CanResetPassword; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; -use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; +use Illuminate\Foundation\Auth\User as Authenticatable; -class User extends Model implements AuthenticatableContract, CanResetPasswordContract +class User extends Authenticatable { - use Authenticatable, CanResetPassword; - - /** - * The database table used by the model. - * - * @var string - */ - protected $table = 'users'; - /** * The attributes that are mass assignable. * * @var array */ - protected $fillable = ['name', 'email', 'password']; + protected $fillable = [ + 'name', 'email', 'password', + ]; /** * The attributes excluded from the model's JSON form. * * @var array */ - protected $hidden = ['password', 'remember_token']; + protected $hidden = [ + 'password', 'remember_token', + ]; } diff --git a/config/app.php b/config/app.php index f141ed7..3309908 100644 --- a/config/app.php +++ b/config/app.php @@ -2,6 +2,19 @@ return [ + /* + |-------------------------------------------------------------------------- + | Application Environment + |-------------------------------------------------------------------------- + | + | This value determines the "environment" your application is currently + | running in. This may determine how you prefer to configure various + | services your application utilizes. Set this in your ".env" file. + | + */ + + 'env' => env('APP_ENV', 'production'), + /* |-------------------------------------------------------------------------- | Application Debug Mode @@ -78,7 +91,7 @@ return [ | */ - 'key' => env('APP_KEY', 'SomeRandomString'), + 'key' => env('APP_KEY'), 'cipher' => 'AES-256-CBC', @@ -113,13 +126,11 @@ return [ /* * Laravel Framework Service Providers... */ - Illuminate\Foundation\Providers\ArtisanServiceProvider::class, Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, - Illuminate\Routing\ControllerServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, @@ -169,7 +180,6 @@ return [ 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, - 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, @@ -179,8 +189,6 @@ return [ 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Hash' => Illuminate\Support\Facades\Hash::class, - 'Input' => Illuminate\Support\Facades\Input::class, - 'Inspiring' => Illuminate\Foundation\Inspiring::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, diff --git a/config/auth.php b/config/auth.php index 7f4a87f..3fa7f49 100644 --- a/config/auth.php +++ b/config/auth.php @@ -4,64 +4,104 @@ return [ /* |-------------------------------------------------------------------------- - | Default Authentication Driver + | Authentication Defaults |-------------------------------------------------------------------------- | - | This option controls the authentication driver that will be utilized. - | This driver manages the retrieval and authentication of the users - | attempting to get access to protected areas of your application. + | This option controls the default authentication "guard" and password + | reset options for your application. You may change these defaults + | as required, but they're a perfect start for most applications. + | + */ + + 'defaults' => [ + 'guard' => 'web', + 'passwords' => 'users', + ], + + /* + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | here which uses session storage and the Eloquent user provider. + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | Supported: "session", "token" + | + */ + + 'guards' => [ + 'web' => [ + 'driver' => 'session', + 'provider' => 'users', + ], + + 'api' => [ + 'driver' => 'token', + 'provider' => 'users', + ], + ], + + /* + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | If you have multiple user tables or models you may configure multiple + | sources which represent each model / table. These sources may then + | be assigned to any extra authentication guards you have defined. | | Supported: "database", "eloquent" | */ - 'driver' => 'eloquent', + 'providers' => [ + 'users' => [ + 'driver' => 'eloquent', + 'model' => App\User::class, + ], + + // 'users' => [ + // 'driver' => 'database', + // 'table' => 'users', + // ], + ], /* |-------------------------------------------------------------------------- - | Authentication Model - |-------------------------------------------------------------------------- - | - | When using the "Eloquent" authentication driver, we need to know which - | Eloquent model should be used to retrieve your users. Of course, it - | is often just the "User" model but you may use whatever you like. - | - */ - - 'model' => App\User::class, - - /* - |-------------------------------------------------------------------------- - | Authentication Table - |-------------------------------------------------------------------------- - | - | When using the "Database" authentication driver, we need to know which - | table should be used to retrieve your users. We have chosen a basic - | default value but you may easily change it to any table you like. - | - */ - - 'table' => 'users', - - /* - |-------------------------------------------------------------------------- - | Password Reset Settings + | Resetting Passwords |-------------------------------------------------------------------------- | | Here you may set the options for resetting passwords including the view - | that is your password reset e-mail. You can also set the name of the + | that is your password reset e-mail. You may also set the name of the | table that maintains all of the reset tokens for your application. | + | You may specify multiple password reset configurations if you have more + | than one user table or model in the application and you want to have + | separate password reset settings based on the specific user types. + | | The expire time is the number of minutes that the reset token should be | considered valid. This security feature keeps tokens short-lived so | they have less time to be guessed. You may change this as needed. | */ - 'password' => [ - 'email' => 'emails.password', - 'table' => 'password_resets', - 'expire' => 60, + 'passwords' => [ + 'users' => [ + 'provider' => 'users', + 'email' => 'auth.emails.password', + 'table' => 'password_resets', + 'expire' => 60, + ], ], ]; diff --git a/config/mail.php b/config/mail.php index a22807e..cb783c9 100644 --- a/config/mail.php +++ b/config/mail.php @@ -108,17 +108,4 @@ return [ 'sendmail' => '/usr/sbin/sendmail -bs', - /* - |-------------------------------------------------------------------------- - | Mail "Pretend" - |-------------------------------------------------------------------------- - | - | When this option is enabled, e-mail will not actually be sent over the - | web and will instead be written to your application's logs files so - | you may inspect the message. This is great for local development. - | - */ - - 'pretend' => false, - ]; diff --git a/config/queue.php b/config/queue.php index cf9b09d..38fa540 100644 --- a/config/queue.php +++ b/config/queue.php @@ -12,7 +12,7 @@ return [ | syntax for each one. Here you may set the default queue driver. | | Supported: "null", "sync", "database", "beanstalkd", - | "sqs", "iron", "redis" + | "sqs", "redis" | */ @@ -53,19 +53,11 @@ return [ 'driver' => 'sqs', 'key' => 'your-public-key', 'secret' => 'your-secret-key', - 'queue' => 'your-queue-url', + 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', + 'queue' => 'your-queue-name', 'region' => 'us-east-1', ], - 'iron' => [ - 'driver' => 'iron', - 'host' => 'mq-aws-us-east-1.iron.io', - 'token' => 'your-token', - 'project' => 'your-project-id', - 'queue' => 'your-queue-name', - 'encrypt' => true, - ], - 'redis' => [ 'driver' => 'redis', 'connection' => 'default', diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 988ea21..2a28edd 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -1,7 +1,6 @@ call(UserTableSeeder::class); - - Model::reguard(); } } diff --git a/phpspec.yml b/phpspec.yml deleted file mode 100644 index eb57939..0000000 --- a/phpspec.yml +++ /dev/null @@ -1,5 +0,0 @@ -suites: - main: - namespace: App - psr4_prefix: App - src_path: app \ No newline at end of file