diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 2cc435b..3dabc68 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,7 +3,9 @@ namespace App\Exceptions; use Exception; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler @@ -15,6 +17,7 @@ class Handler extends ExceptionHandler */ protected $dontReport = [ HttpException::class, + ModelNotFoundException::class, ]; /** @@ -39,6 +42,10 @@ public function report(Exception $e) */ public function render($request, Exception $e) { + if ($e instanceof ModelNotFoundException) { + $e = new NotFoundHttpException($e->getMessage(), $e); + } + return parent::render($request, $e); } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 9be752a..4eb37d5 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -5,8 +5,9 @@ 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 { - use DispatchesJobs, ValidatesRequests; + use AuthorizesRequests, DispatchesJobs, ValidatesRequests; } diff --git a/app/Jobs/Job.php b/app/Jobs/Job.php index d99ae7e..55ece29 100644 --- a/app/Jobs/Job.php +++ b/app/Jobs/Job.php @@ -13,7 +13,7 @@ abstract class Job | | This job base class provides a central location to place any logic that | is shared across all of your jobs. The trait included with the class - | provides access to the "queueOn" and "delay" queue helper methods. + | provides access to the "onQueue" and "delay" queue helper methods. | */ diff --git a/app/Policies/.gitkeep b/app/Policies/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php new file mode 100644 index 0000000..9b35830 --- /dev/null +++ b/app/Providers/AuthServiceProvider.php @@ -0,0 +1,31 @@ + 'App\Policies\ModelPolicy', + ]; + + /** + * Register any application authentication / authorization services. + * + * @param \Illuminate\Contracts\Auth\Access\Gate $gate + * @return void + */ + public function boot(GateContract $gate) + { + parent::registerPolicies($gate); + + // + } +} diff --git a/app/User.php b/app/User.php index 86eabed..9f1e748 100644 --- a/app/User.php +++ b/app/User.php @@ -5,12 +5,16 @@ use Illuminate\Auth\Authenticatable; use Illuminate\Database\Eloquent\Model; use Illuminate\Auth\Passwords\CanResetPassword; +use Illuminate\Foundation\Auth\Access\Authorizable; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; +use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; -class User extends Model implements AuthenticatableContract, CanResetPasswordContract +class User extends Model implements AuthenticatableContract, + AuthorizableContract, + CanResetPasswordContract { - use Authenticatable, CanResetPassword; + use Authenticatable, Authorizable, CanResetPassword; /** * The database table used by the model. diff --git a/config/app.php b/config/app.php index 3f800da..32627a7 100644 --- a/config/app.php +++ b/config/app.php @@ -141,6 +141,7 @@ * Application Service Providers... */ App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, @@ -180,6 +181,7 @@ 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, + 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Input' => Illuminate\Support\Facades\Input::class, 'Inspiring' => Illuminate\Foundation\Inspiring::class, diff --git a/config/services.php b/config/services.php index 51abbbd..93eec86 100644 --- a/config/services.php +++ b/config/services.php @@ -15,24 +15,24 @@ */ 'mailgun' => [ - 'domain' => '', - 'secret' => '', + 'domain' => env('MAILGUN_DOMAIN'), + 'secret' => env('MAILGUN_SECRET'), ], 'mandrill' => [ - 'secret' => '', + 'secret' => env('MANDRILL_SECRET'), ], 'ses' => [ - 'key' => '', - 'secret' => '', + 'key' => env('SES_KEY'), + 'secret' => env('SES_SECRET'), 'region' => 'us-east-1', ], 'stripe' => [ 'model' => App\User::class, - 'key' => '', - 'secret' => '', + 'key' => env('STRIPE_KEY'), + 'secret' => env('STRIPE_SECRET'), ], ]; diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index ae7165b..0876c70 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -11,11 +11,11 @@ | */ -$factory->define(App\User::class, function ($faker) { +$factory->define(App\User::class, function (Faker\Generator $faker) { return [ 'name' => $faker->name, 'email' => $faker->email, - 'password' => str_random(10), + 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10), ]; }); diff --git a/package.json b/package.json index b1b4a6e..8b7c633 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "gulp": "^3.8.8" }, "dependencies": { - "laravel-elixir": "^2.0.0", + "laravel-elixir": "^3.0.0", "bootstrap-sass": "^3.0.0" } } diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php new file mode 100644 index 0000000..e5506df --- /dev/null +++ b/resources/lang/en/auth.php @@ -0,0 +1,19 @@ + 'These credentials do not match our records.', + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', + +]; diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php index 7c10cba..e6f3a67 100644 --- a/resources/lang/en/passwords.php +++ b/resources/lang/en/passwords.php @@ -14,9 +14,9 @@ */ 'password' => 'Passwords must be at least six characters and match the confirmation.', - 'user' => "We can't find a user with that e-mail address.", - 'token' => 'This password reset token is invalid.', - 'sent' => 'We have e-mailed your password reset link!', 'reset' => 'Your password has been reset!', + 'sent' => 'We have e-mailed your password reset link!', + 'token' => 'This password reset token is invalid.', + 'user' => "We can't find a user with that e-mail address.", ]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 20acc9a..c7a1ecf 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -35,12 +35,13 @@ 'digits' => 'The :attribute must be :digits digits.', 'digits_between' => 'The :attribute must be between :min and :max digits.', 'email' => 'The :attribute must be a valid email address.', - 'filled' => 'The :attribute field is required.', 'exists' => 'The selected :attribute is invalid.', + 'filled' => 'The :attribute field is required.', 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', 'integer' => 'The :attribute must be an integer.', 'ip' => 'The :attribute must be a valid IP address.', + 'json' => 'The :attribute must be a valid JSON string.', 'max' => [ 'numeric' => 'The :attribute may not be greater than :max.', 'file' => 'The :attribute may not be greater than :max kilobytes.', diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php index 0380666..4a41505 100644 --- a/resources/views/errors/503.blade.php +++ b/resources/views/errors/503.blade.php @@ -3,7 +3,7 @@ Be right back. - +