aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Console/Commands/.gitkeep0
-rw-r--r--app/Console/Kernel.php15
-rw-r--r--app/Events/Event.php10
-rw-r--r--app/Exceptions/Handler.php39
-rw-r--r--app/Http/Controllers/Auth/ForgotPasswordController.php32
-rw-r--r--app/Http/Controllers/Auth/LoginController.php39
-rw-r--r--app/Http/Controllers/Auth/RegisterController.php76
-rw-r--r--app/Http/Controllers/Auth/ResetPasswordController.php34
-rw-r--r--app/Http/Controllers/Controller.php7
-rw-r--r--app/Http/Controllers/RandomVerbController.php3
-rw-r--r--app/Http/Controllers/RootController.php3
-rw-r--r--app/Http/Controllers/UserController.php67
-rw-r--r--app/Http/Controllers/VerbController.php5
-rw-r--r--app/Http/Kernel.php56
-rw-r--r--app/Http/Middleware/Authenticate.php45
-rw-r--r--app/Http/Middleware/EncryptCookies.php17
-rw-r--r--app/Http/Middleware/Login.php34
-rw-r--r--app/Http/Middleware/RedirectIfAuthenticated.php (renamed from app/Http/Middleware/ExampleMiddleware.php)10
-rw-r--r--app/Http/Middleware/VerifyCsrfToken.php17
-rw-r--r--app/Http/routes.php88
-rw-r--r--app/Jobs/Job.php25
-rw-r--r--app/Listeners/Listener.php11
-rw-r--r--app/Providers/AppServiceProvider.php33
-rw-r--r--app/Providers/AuthServiceProvider.php49
-rw-r--r--app/Providers/BroadcastServiceProvider.php26
-rw-r--r--app/Providers/EventServiceProvider.php13
-rw-r--r--app/Providers/RouteServiceProvider.php79
-rw-r--r--app/User.php18
28 files changed, 498 insertions, 353 deletions
diff --git a/app/Console/Commands/.gitkeep b/app/Console/Commands/.gitkeep
deleted file mode 100644
index e69de29..0000000
--- a/app/Console/Commands/.gitkeep
+++ /dev/null
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index ad6e311..622e774 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -3,7 +3,7 @@
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
-use Laravel\Lumen\Console\Kernel as ConsoleKernel;
+use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
@@ -24,6 +24,17 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
- //
+ // $schedule->command('inspire')
+ // ->hourly();
+ }
+
+ /**
+ * Register the Closure based commands for the application.
+ *
+ * @return void
+ */
+ protected function commands()
+ {
+ require base_path('routes/console.php');
}
}
diff --git a/app/Events/Event.php b/app/Events/Event.php
deleted file mode 100644
index b8230f0..0000000
--- a/app/Events/Event.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-namespace App\Events;
-
-use Illuminate\Queue\SerializesModels;
-
-abstract class Event
-{
- use SerializesModels;
-}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 8d0b13e..21c9784 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -3,8 +3,8 @@
namespace App\Exceptions;
use Exception;
-use Symfony\Component\HttpKernel\Exception\HttpException;
-use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
+use Illuminate\Auth\AuthenticationException;
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
@@ -14,7 +14,12 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
- HttpException::class,
+ \Illuminate\Auth\AuthenticationException::class,
+ \Illuminate\Auth\Access\AuthorizationException::class,
+ \Symfony\Component\HttpKernel\Exception\HttpException::class,
+ \Illuminate\Database\Eloquent\ModelNotFoundException::class,
+ \Illuminate\Session\TokenMismatchException::class,
+ \Illuminate\Validation\ValidationException::class,
];
/**
@@ -22,23 +27,39 @@ class Handler extends ExceptionHandler
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
- * @param \Exception $e
+ * @param \Exception $exception
* @return void
*/
- public function report(Exception $e)
+ public function report(Exception $exception)
{
- return parent::report($e);
+ parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
- * @param \Exception $e
+ * @param \Exception $exception
* @return \Illuminate\Http\Response
*/
- public function render($request, Exception $e)
+ public function render($request, Exception $exception)
{
- return parent::render($request, $e);
+ return parent::render($request, $exception);
+ }
+
+ /**
+ * Convert an authentication exception into an unauthenticated response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Auth\AuthenticationException $exception
+ * @return \Illuminate\Http\Response
+ */
+ protected function unauthenticated($request, AuthenticationException $exception)
+ {
+ if ($request->expectsJson()) {
+ return response()->json(['error' => 'Unauthenticated.'], 401);
+ }
+
+ return redirect()->guest('login');
}
}
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
new file mode 100644
index 0000000..a36a6f4
--- /dev/null
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
+
+class ForgotPasswordController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Password Reset Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller is responsible for handling password reset emails and
+ | includes a trait which assists in sending these notifications from
+ | your application to your users. Feel free to explore this trait.
+ |
+ */
+
+ use SendsPasswordResetEmails;
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ }
+}
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
new file mode 100644
index 0000000..4c81bea
--- /dev/null
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\AuthenticatesUsers;
+
+class LoginController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Login Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller handles authenticating users for the application and
+ | redirecting them to your home screen. The controller uses a trait
+ | to conveniently provide its functionality to your applications.
+ |
+ */
+
+ use AuthenticatesUsers;
+
+ /**
+ * Where to redirect users after login.
+ *
+ * @var string
+ */
+ protected $redirectTo = '/contribute';
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest', ['except' => 'logout']);
+ }
+}
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
new file mode 100644
index 0000000..ed46cab
--- /dev/null
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use HebrewParseTrainer\User;
+use Validator;
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\RegistersUsers;
+
+class RegisterController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Register Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller handles the registration of new users as well as their
+ | validation and creation. By default this controller uses a trait to
+ | provide this functionality without requiring any additional code.
+ |
+ */
+
+ use RegistersUsers;
+
+ /**
+ * Where to redirect users after login / registration.
+ *
+ * @var string
+ */
+ protected $redirectTo = '/';
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ }
+
+ /**
+ * Get a validator for an incoming registration request.
+ *
+ * @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',
+ 'password' => 'required|min:6|confirmed',
+ ]);
+ }
+
+ /**
+ * Create a new user instance after a valid registration.
+ *
+ * @param array $data
+ * @return User
+ */
+ protected function create(array $data)
+ {
+ $user = new User([
+ 'name' => $data['name'],
+ 'email' => $data['email'],
+ ]);
+
+ $user->password = $data['password'];
+
+ $user->save();
+
+ return $user;
+ }
+}
diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php
new file mode 100644
index 0000000..98d1131
--- /dev/null
+++ b/app/Http/Controllers/Auth/ResetPasswordController.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\ResetsPasswords;
+
+class ResetPasswordController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Password Reset Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller is responsible for handling password reset requests
+ | and uses a simple trait to include this behavior. You're free to
+ | explore this trait and override any methods you wish to tweak.
+ |
+ */
+
+ use ResetsPasswords;
+
+ protected $redirectTo = '/';
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ }
+}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 0ccb918..03e02a2 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -2,9 +2,12 @@
namespace App\Http\Controllers;
-use Laravel\Lumen\Routing\Controller as BaseController;
+use Illuminate\Foundation\Bus\DispatchesJobs;
+use Illuminate\Routing\Controller as BaseController;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
- //
+ use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
diff --git a/app/Http/Controllers/RandomVerbController.php b/app/Http/Controllers/RandomVerbController.php
index 501440a..ceb5ff9 100644
--- a/app/Http/Controllers/RandomVerbController.php
+++ b/app/Http/Controllers/RandomVerbController.php
@@ -22,9 +22,8 @@ use HebrewParseTrainer\Verb;
use HebrewParseTrainer\RandomLog;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
-use Laravel\Lumen\Routing\Controller as BaseController;
-class RandomVerbController extends BaseController {
+class RandomVerbController extends Controller {
public function show()
{
diff --git a/app/Http/Controllers/RootController.php b/app/Http/Controllers/RootController.php
index 3899754..5546a1d 100644
--- a/app/Http/Controllers/RootController.php
+++ b/app/Http/Controllers/RootController.php
@@ -21,12 +21,11 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
-use Laravel\Lumen\Routing\Controller as BaseController;
use HebrewParseTrainer\Root;
use HebrewParseTrainer\RootKind;
-class RootController extends BaseController {
+class RootController extends Controller {
public function create(Request $request) {
$_kinds = RootKind::all();
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
deleted file mode 100644
index 7036439..0000000
--- a/app/Http/Controllers/UserController.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * HebrewParseTrainer - practice Hebrew verbs
- * Copyright (C) 2015 Camil Staps <info@camilstaps.nl>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Validator;
-use Illuminate\Validation\ValidationException;
-use Laravel\Lumen\Routing\Controller as BaseController;
-
-use HebrewParseTrainer\User;
-
-class UserController extends BaseController {
-
- public function createForm(Request $request) {
- $messages = [];
-
- if ($request->isMethod('post')) {
- $validator = Validator::make($request->input(), [
- 'email' => 'required|unique:users|email',
- 'name' => 'required|unique:users',
- 'password' => 'required|confirmed|min:8',
- ]);
-
- if ($validator->fails()) {
- foreach ($validator->errors()->all() as $error) {
- $messages[] = ['danger', $error];
- }
- } else {
- $user = new User;
- $user->name = $request->input('name');
- $user->email = $request->input('email');
- $user->password = $request->input('password');
- if ($user->save()) {
- $messages[] = ['success', 'Your account has been created.'];
- } else {
- $messages[] = ['danger', 'Your account could not be created.'];
- }
- }
- }
-
- return view('user.create',
- [
- 'messages' => $messages,
- 'form' => [
- 'email' => $request->input('email'),
- 'name' => $request->input('name')
- ]
- ]);
- }
-
-}
diff --git a/app/Http/Controllers/VerbController.php b/app/Http/Controllers/VerbController.php
index 18cdd2f..59289c1 100644
--- a/app/Http/Controllers/VerbController.php
+++ b/app/Http/Controllers/VerbController.php
@@ -29,9 +29,8 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator;
-use Laravel\Lumen\Routing\Controller as BaseController;
-class VerbController extends BaseController {
+class VerbController extends Controller {
public function random() {
$verbs = Verb::where('active', 1)->get();
@@ -129,7 +128,7 @@ class VerbController extends BaseController {
return true;
}
- public function vote($choice, $verb_id) {
+ public function vote($verb_id, $choice) {
$verb = Verb::findOrFail($verb_id);
$user = Auth::user();
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
new file mode 100644
index 0000000..85782f3
--- /dev/null
+++ b/app/Http/Kernel.php
@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Http;
+
+use Illuminate\Foundation\Http\Kernel as HttpKernel;
+
+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,
+ ];
+
+ /**
+ * 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,
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ ],
+
+ 'api' => [
+ 'throttle:60,1',
+ 'bindings',
+ ],
+ ];
+
+ /**
+ * The application's route middleware.
+ *
+ * These middleware may be assigned to groups or used individually.
+ *
+ * @var array
+ */
+ protected $routeMiddleware = [
+ 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
+ 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+ 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ 'can' => \Illuminate\Auth\Middleware\Authorize::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
deleted file mode 100644
index 6db8bb0..0000000
--- a/app/Http/Middleware/Authenticate.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Closure;
-use Illuminate\Contracts\Auth\Factory as Auth;
-
-class Authenticate
-{
- /**
- * The authentication guard factory instance.
- *
- * @var \Illuminate\Contracts\Auth\Factory
- */
- protected $auth;
-
- /**
- * Create a new middleware instance.
- *
- * @param \Illuminate\Contracts\Auth\Factory $auth
- * @return void
- */
- public function __construct(Auth $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, $guard = null)
- {
- if ($this->auth->guard($guard)->guest()) {
- return response('Unauthorized.', 401)
- ->header('WWW-Authenticate', 'Basic realm="Please enter your email and password"');
- }
-
- return $next($request);
- }
-}
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
new file mode 100644
index 0000000..3aa15f8
--- /dev/null
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
+
+class EncryptCookies extends BaseEncrypter
+{
+ /**
+ * The names of the cookies that should not be encrypted.
+ *
+ * @var array
+ */
+ protected $except = [
+ //
+ ];
+}
diff --git a/app/Http/Middleware/Login.php b/app/Http/Middleware/Login.php
deleted file mode 100644
index 8a71104..0000000
--- a/app/Http/Middleware/Login.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-namespace App\Http\Middleware;
-
-use Closure;
-use Illuminate\Support\Facades\Auth;
-
-class Login {
- /**
- * Create a new middleware instance.
- *
- * @param \Illuminate\Contracts\Auth\Factory $auth
- * @return void
- */
- public function __construct() {
- }
-
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @param string|null $guard
- * @return mixed
- */
- public function handle($request, Closure $next, $guard = null) {
- if ($request->has('login') && !Auth::check()) {
- return response('Unauthorized.', 401)
- ->header('WWW-Authenticate', 'Basic realm="Please enter your email and password"');
- }
-
- return $next($request);
- }
-}
diff --git a/app/Http/Middleware/ExampleMiddleware.php b/app/Http/Middleware/RedirectIfAuthenticated.php
index 166581c..e27860e 100644
--- a/app/Http/Middleware/ExampleMiddleware.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -3,18 +3,24 @@
namespace App\Http\Middleware;
use Closure;
+use Illuminate\Support\Facades\Auth;
-class ExampleMiddleware
+class RedirectIfAuthenticated
{
/**
* 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 (Auth::guard($guard)->check()) {
+ return redirect('/');
+ }
+
return $next($request);
}
}
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
new file mode 100644
index 0000000..a2c3541
--- /dev/null
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
+
+class VerifyCsrfToken extends BaseVerifier
+{
+ /**
+ * The URIs that should be excluded from CSRF verification.
+ *
+ * @var array
+ */
+ protected $except = [
+ //
+ ];
+}
diff --git a/app/Http/routes.php b/app/Http/routes.php
deleted file mode 100644
index b233efa..0000000
--- a/app/Http/routes.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * HebrewParseTrainer - practice Hebrew verbs
- * Copyright (C) 2015 Camil Staps <info@camilstaps.nl>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
-|--------------------------------------------------------------------------
-| Application Routes
-|--------------------------------------------------------------------------
-|
-| Here is where you can register all of the routes for an application.
-| It is a breeze. Simply tell Lumen the URIs it should respond to
-| and give it the Closure to call when that URI is requested.
-|
-*/
-
-$app->group(
- [
- 'prefix' => parse_url(env('APP_URL'), PHP_URL_PATH),
- 'middleware' => 'login'
- ],
- function ($app) {
-
- $app->get('/', function () use ($app) {
- return view('trainer');
- });
-
- $app->get('/stem', function () use ($app) {
- return \HebrewParseTrainer\Stem::all();
- });
-
- $app->get('/tense', function () use ($app) {
- return \HebrewParseTrainer\Tense::all();
- });
-
- $app->get('/verb/random',
- 'App\Http\Controllers\VerbController@random');
-
- $app->get('/logout', function () use ($app) {
- return response('You have been logged out.', 401)
- ->header(
- 'WWW-Authenticate',
- 'Basic realm="Please click OK, then Cancel to logout."');
- });
-
- $app->get('/contribute', function () use ($app) {
- return view('contribute');
- });
-
- $app->get('/user/create',
- 'App\Http\Controllers\UserController@createForm');
- $app->post('/user/create',
- 'App\Http\Controllers\UserController@createForm');
-
- $app->group(
- ['middleware' => 'auth:basic-http'],
- function ($app) {
-
- $app->get('/stats', function () use ($app) {
- return view('stats');
- });
-
- $app->get('/verb/{id}/vote/{choice}',
- 'App\Http\Controllers\VerbController@vote');
-
- $app->post('/verb/suggest',
- 'App\Http\Controllers\VerbController@suggest');
-
- $app->post('/root/create',
- 'App\Http\Controllers\RootController@create');
-
- });
-
-});
diff --git a/app/Jobs/Job.php b/app/Jobs/Job.php
deleted file mode 100644
index 2bc4975..0000000
--- a/app/Jobs/Job.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use Illuminate\Bus\Queueable;
-use Illuminate\Queue\SerializesModels;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Contracts\Bus\SelfHandling;
-use Illuminate\Contracts\Queue\ShouldQueue;
-
-abstract class Job implements SelfHandling, ShouldQueue
-{
- /*
- |--------------------------------------------------------------------------
- | Queueable Jobs
- |--------------------------------------------------------------------------
- |
- | 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.
- |
- */
-
- use InteractsWithQueue, Queueable, SerializesModels;
-}
diff --git a/app/Listeners/Listener.php b/app/Listeners/Listener.php
deleted file mode 100644
index d346fc1..0000000
--- a/app/Listeners/Listener.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-namespace App\Listeners;
-
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Contracts\Queue\ShouldQueue;
-
-abstract class Listener
-{
- //
-}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 9bc5fd1..35471f6 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -3,23 +3,26 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
-use App\Observers\UserObserver;
-use HebrewParseTrainer\User;
class AppServiceProvider extends ServiceProvider
{
- /**
- * Register any application services.
- *
- * @return void
- */
- public function register()
- {
- $this->app->singleton('mailer', function ($app) {
- $app->configure('services');
- return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer');
- });
+ /**
+ * Bootstrap any application services.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ //
+ }
- User::observe(UserObserver::class);
- }
+ /**
+ * Register any application services.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ //
+ }
}
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
index 7cf4b27..9784b1a 100644
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@ -2,38 +2,29 @@
namespace App\Providers;
-use App\User;
-use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
-use Illuminate\Support\ServiceProvider;
+use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
- /**
- * Register any application services.
- *
- * @return void
- */
- public function register()
- {
- //
- }
+ /**
+ * The policy mappings for the application.
+ *
+ * @var array
+ */
+ protected $policies = [
+ 'App\Model' => 'App\Policies\ModelPolicy',
+ ];
- /**
- * Boot the authentication services for the application.
- *
- * @return void
- */
- public function boot()
- {
- // Here you may define how you wish users to be authenticated for your Lumen
- // application. The callback which receives the incoming request instance
- // should return either a User instance or null. You're free to obtain
- // the User instance via an API token or any other method necessary.
- Auth::viaRequest('api', function ($request) {
- if ($request->input('api_token')) {
- return User::where('api_token', $request->input('api_token'))->first();
- }
- });
- }
+ /**
+ * Register any authentication / authorization services.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ $this->registerPolicies();
+
+ //
+ }
}
diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php
new file mode 100644
index 0000000..1dcf8d2
--- /dev/null
+++ b/app/Providers/BroadcastServiceProvider.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\ServiceProvider;
+use Illuminate\Support\Facades\Broadcast;
+
+class BroadcastServiceProvider extends ServiceProvider
+{
+ /**
+ * Bootstrap any application services.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ Broadcast::routes();
+
+ /*
+ * Authenticate the user's personal channel...
+ */
+ Broadcast::channel('App.User.*', function ($user, $userId) {
+ return (int) $user->id === (int) $userId;
+ });
+ }
+}
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index ff72210..a182657 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -2,6 +2,7 @@
namespace App\Providers;
+use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
@@ -16,4 +17,16 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\EventListener',
],
];
+
+ /**
+ * Register any events for your application.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ parent::boot();
+
+ //
+ }
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
new file mode 100644
index 0000000..87ffb05
--- /dev/null
+++ b/app/Providers/RouteServiceProvider.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\Facades\Route;
+use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
+
+class RouteServiceProvider extends ServiceProvider
+{
+ /**
+ * This namespace is applied to your controller routes.
+ *
+ * In addition, it is set as the URL generator's root namespace.
+ *
+ * @var string
+ */
+ protected $namespace = 'App\Http\Controllers';
+
+ /**
+ * Define your route model bindings, pattern filters, etc.
+ *
+ * @return void
+ */
+ public function boot()
+ {
+ //
+
+ parent::boot();
+ }
+
+ /**
+ * Define the routes for the application.
+ *
+ * @return void
+ */
+ public function map()
+ {
+ $this->mapApiRoutes();
+
+ $this->mapWebRoutes();
+
+ //
+ }
+
+ /**
+ * Define the "web" routes for the application.
+ *
+ * These routes all receive session state, CSRF protection, etc.
+ *
+ * @return void
+ */
+ protected function mapWebRoutes()
+ {
+ Route::group([
+ 'middleware' => 'web',
+ 'namespace' => $this->namespace,
+ ], function ($router) {
+ require base_path('routes/web.php');
+ });
+ }
+
+ /**
+ * Define the "api" routes for the application.
+ *
+ * These routes are typically stateless.
+ *
+ * @return void
+ */
+ protected function mapApiRoutes()
+ {
+ Route::group([
+ 'middleware' => 'api',
+ 'namespace' => $this->namespace,
+ 'prefix' => 'api',
+ ], function ($router) {
+ require base_path('routes/api.php');
+ });
+ }
+}
diff --git a/app/User.php b/app/User.php
index f1ff869..8853733 100644
--- a/app/User.php
+++ b/app/User.php
@@ -19,10 +19,16 @@
namespace HebrewParseTrainer;
use Illuminate\Contracts\Auth\Authenticatable;
+use Illuminate\Contracts\Auth\CanResetPassword;
+use Illuminate\Auth\Passwords\CanResetPassword as CanResetPasswordTrait;
+use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;
-class User extends Model implements Authenticatable {
+class User extends Model implements Authenticatable, CanResetPassword {
+
+ use CanResetPasswordTrait;
+ use Notifiable;
protected $table = 'users';
public $timestamps = false;
@@ -52,10 +58,6 @@ class User extends Model implements Authenticatable {
return floor(log($this->points, self::VOTE_WEIGHT_BASE));
}
- public function setPasswordAttribute($pass) {
- $this->attributes['password'] = Hash::make($pass);
- }
-
public function verifyPassword($pass) {
if (!Hash::check($pass, $this->password))
return false;
@@ -81,14 +83,16 @@ class User extends Model implements Authenticatable {
}
public function getRememberToken() {
- return null;
+ return $this->remember_token;
}
public function setRememberToken($token) {
+ $this->remember_token = $token;
+ $this->save();
}
public function getRememberTokenName() {
- return null;
+ return 'remember_token';
}
}