Page MenuHomeDevCentral

D412.diff
No OneTemporary

D412.diff

diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php
--- a/app/Http/Controllers/Auth/AuthController.php
+++ b/app/Http/Controllers/Auth/AuthController.php
@@ -1,42 +1,78 @@
-<?php namespace AuthGrove\Http\Controllers\Auth;
+<?php
+
+namespace AuthGrove\Http\Controllers\Auth;
+
+use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
+use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
+use Illuminate\Foundation\Auth\ThrottlesLogins;
use AuthGrove\Http\Controllers\Controller;
-use Illuminate\Contracts\Auth\Guard;
-use Illuminate\Contracts\Auth\Registrar;
-use Illuminate\Contracts\Auth\PasswordBroker;
-use AuthGrove\Services\AuthenticatesAndRegistersUsers;
-use AuthGrove\Services\ResetsPasswords;
-
-class AuthController extends Controller {
-
- /*
- |--------------------------------------------------------------------------
- | Registration & Login Controller
- |--------------------------------------------------------------------------
- |
- | This controller handles the registration of new users, as well as the
- | authentication of existing users. By default, this controller uses
- | a simple trait to add these behaviors. Why don't you explore it?
- |
- */
-
- use AuthenticatesAndRegistersUsers;
- use ResetsPasswords;
-
- /**
- * Create a new authentication controller instance.
- *
- * @param \Illuminate\Contracts\Auth\Guard $auth
- * @param \Illuminate\Contracts\Auth\Registrar $registrar
- * @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
- * @return void
- */
- public function __construct(Guard $auth, Registrar $registrar, PasswordBroker $passwords)
- {
- $this->auth = $auth;
- $this->registrar = $registrar;
- $this->passwords = $passwords;
-
- $this->middleware('guest', ['except' => 'getLogout']);
- }
+use AuthGrove\Services\Registrar;
+use AuthGrove\User;
+
+use Route;
+
+class AuthController extends Controller implements RegistrarContract
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Registration & Login Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller handles the registration of new users, as well as the
+ | authentication of existing users. By default, this controller uses
+ | a simple trait to add these behaviors. Why don't you explore it?
+ |
+ */
+
+ use AuthenticatesAndRegistersUsers, ThrottlesLogins, Registrar;
+
+ /**
+ * Where to redirect users after login / registration.
+ *
+ * @var string
+ */
+ protected $redirectTo = '/';
+
+ /**
+ * The field to use as username
+ *
+ * @var string
+ */
+ protected $username = 'username';
+
+ /**
+ * Create a new authentication controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
+ }
+
+ /**
+ * Register auth routes
+ */
+ public static function registerRoutes () {
+ // Login
+ Route::get('/auth', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@showLoginForm']);
+ Route::get('/auth/login', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@showLoginForm']);
+ Route::post('/auth/login', ['as' => 'auth.login', 'uses' => 'Auth\AuthController@login']);
+
+ // Logout
+ Route::get('/auth/logout', ['as' => 'auth.logout', 'uses' => 'Auth\AuthController@logout']);
+
+ // Registration
+ Route::get('/auth/register', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@showRegistrationForm']);
+ Route::post('/auth/register', ['as' => 'auth.register', 'uses' => 'Auth\AuthController@register']);
+
+ // Recover account
+ Route::get('/auth/recover', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@getRecover']);
+ Route::post('/auth/recover', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@postRecover']);
+
+ // Reset password (with a token received by mail)
+ Route::get('/auth/reset/{token?}', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@getReset']);
+ Route::post('/auth/reset', ['as' => 'auth.password.reset', 'uses' => 'Auth\PasswordController@reset']);
+ }
}
diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php
new file mode 100644
--- /dev/null
+++ b/app/Http/Controllers/Auth/PasswordController.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace AuthGrove\Http\Controllers\Auth;
+
+use AuthGrove\Http\Controllers\Controller;
+use AuthGrove\Services\ResetsPasswords;
+
+class PasswordController 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;
+
+ /**
+ * Where to redirect users after login / registration.
+ *
+ * @var string
+ */
+ protected $redirectPath = '/';
+
+ /**
+ * Create a new password controller instance.
+ *
+ * @return void
+ */
+ public function __construct() {
+ $this->middleware('guest');
+ }
+}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -1,11 +1,11 @@
<?php namespace AuthGrove\Http\Controllers;
-use Illuminate\Foundation\Bus\DispatchesCommands;
+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 DispatchesCommands, ValidatesRequests;
-
+abstract class Controller extends BaseController
+{
+ use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
diff --git a/app/Http/Controllers/LoginDashboardController.php b/app/Http/Controllers/LoginDashboardController.php
--- a/app/Http/Controllers/LoginDashboardController.php
+++ b/app/Http/Controllers/LoginDashboardController.php
@@ -1,6 +1,6 @@
<?php namespace AuthGrove\Http\Controllers;
-use Illuminate\Support\Facades\Auth;
+use Illuminate\Http\Request;
class LoginDashboardController extends Controller {
@@ -14,27 +14,31 @@
| about their authentication data, methods and connections.
*/
- /**
- * Create a new controller instance.
- *
- * @return void
- */
- public function __construct()
- {
- $this->middleware('auth');
- }
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct() {
+ $this->middleware('auth');
+ }
/**
* Show the application dashboard to the user.
*
+ * @param Request $request
* @return Response
*/
- public function index()
+ public function index(Request $request)
{
+ if (!$user = $request->user()) {
+ throw new \LogicException("The login dashboard controller is called when there isn't any instance of an authenticated user.");
+ }
+
return view(
'home',
[
- 'user' => Auth::user()->getInformation(),
+ 'user' => $user->getInformation(),
]
);
}
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -4,30 +4,45 @@
class Kernel extends HttpKernel {
- /**
- * The application's global HTTP middleware stack.
- *
- * @var array
- */
- protected $middleware = [
- 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
- 'Illuminate\Cookie\Middleware\EncryptCookies',
- 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
- 'Illuminate\Session\Middleware\StartSession',
- 'Illuminate\View\Middleware\ShareErrorsFromSession',
- 'AuthGrove\Http\Middleware\VerifyCsrfToken',
- 'AuthGrove\Http\Middleware\TrustProxy',
- ];
+ /**
+ * The application's global HTTP middleware stack.
+ *
+ * @var array
+ */
+ protected $middleware = [
+ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
+ \AuthGrove\Http\Middleware\TrustProxy::class,
+ ];
- /**
- * The application's route middleware.
- *
- * @var array
- */
- protected $routeMiddleware = [
- 'auth' => 'AuthGrove\Http\Middleware\Authenticate',
- 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
- 'guest' => 'AuthGrove\Http\Middleware\RedirectIfAuthenticated',
- ];
+ /**
+ * The application's route middleware groups.
+ *
+ * @var array
+ */
+ protected $middlewareGroups = [
+ 'web' => [
+ \AuthGrove\Http\Middleware\EncryptCookies::class,
+ \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
+ \Illuminate\Session\Middleware\StartSession::class,
+ \Illuminate\View\Middleware\ShareErrorsFromSession::class,
+ \AuthGrove\Http\Middleware\VerifyCsrfToken::class,
+ ],
+ 'api' => [
+ 'throttle:60,1',
+ ],
+ ];
+
+ /**
+ * The application's route middleware.
+ *
+ * @var array
+ */
+ protected $routeMiddleware = [
+ 'auth' => \AuthGrove\Http\Middleware\Authenticate::class,
+ 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+ 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
+ 'guest' => \AuthGrove\Http\Middleware\RedirectIfAuthenticated::class,
+ 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
+ ];
}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -1,50 +1,26 @@
<?php namespace AuthGrove\Http\Middleware;
use Closure;
-use Illuminate\Contracts\Auth\Guard;
+use Illuminate\Support\Facades\Auth;
class Authenticate {
+ /**
+ * 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 (Auth::guard($guard)->guest()) {
+ if ($request->ajax()) {
+ return response('Unauthorized.', 401);
+ } else {
+ return redirect()->guest('auth/login');
+ }
+ }
- /**
- * 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
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if ($this->auth->guest())
- {
- if ($request->ajax())
- {
- return response('Unauthorized.', 401);
- }
- else
- {
- return redirect()->guest('auth/login');
- }
- }
-
- return $next($request);
- }
-
+ return $next($request);
+ }
}
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
new file mode 100644
--- /dev/null
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace AuthGrove\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/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -1,44 +1,22 @@
<?php namespace AuthGrove\Http\Middleware;
use Closure;
-use Illuminate\Contracts\Auth\Guard;
-use Illuminate\Http\RedirectResponse;
+use Illuminate\Support\Facades\Auth;
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, $guard = null) {
+ if (Auth::guard($guard)->check()) {
+ return redirect('/');
+ }
- /**
- * 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
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if ($this->auth->check())
- {
- return new RedirectResponse(url('/'));
- }
-
- return $next($request);
- }
-
+ return $next($request);
+ }
}
diff --git a/app/Http/Middleware/TrustProxy.php b/app/Http/Middleware/TrustProxy.php
--- a/app/Http/Middleware/TrustProxy.php
+++ b/app/Http/Middleware/TrustProxy.php
@@ -1,6 +1,5 @@
<?php namespace AuthGrove\Http\Middleware;
-use Illuminate\Contracts\Routing\Middleware;
use AuthGrove\Enums\TrustProxyConfigurationMode;
use Config;
use Closure;
@@ -10,7 +9,7 @@
*
* See http://symfony.com/doc/current/cookbook/request/load_balancer_reverse_proxy.html
*/
-class TrustProxy implements Middleware {
+class TrustProxy {
/**
* Handle an incoming request.
*
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -1,20 +1,15 @@
<?php namespace AuthGrove\Http\Middleware;
-use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
-class VerifyCsrfToken extends BaseVerifier {
-
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- return parent::handle($request, $next);
- }
-
+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
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -2,22 +2,33 @@
/*
|--------------------------------------------------------------------------
-| Application Routes
+| Routes File
|--------------------------------------------------------------------------
|
-| Here is where you can register all of the routes for an application.
+| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
-Route::get('/', 'LoginDashboardController@index');
-
//Allows to external tool to ping your instalation and know if the site is up.
Route::get('status', function() {
return "ALIVE";
});
-Route::controllers([
- 'auth' => 'Auth\AuthController',
-]);
+/*
+|--------------------------------------------------------------------------
+| Application Routes
+|--------------------------------------------------------------------------
+|
+| This route group applies the "web" middleware group to every route
+| it contains. The "web" middleware group is defined in your HTTP
+| kernel and includes session state, CSRF protection, and more.
+|
+*/
+
+Route::group(['middleware' => 'web'], function () {
+ AuthGrove\Http\Controllers\Auth\AuthController::registerRoutes();
+
+ Route::get('/', 'LoginDashboardController@index');
+});
diff --git a/app/Jobs/Command.php b/app/Jobs/Command.php
--- a/app/Jobs/Command.php
+++ b/app/Jobs/Command.php
@@ -1,7 +1,21 @@
-<?php namespace AuthGrove\Commands;
+<?php
-abstract class Command {
+namespace AuthGrove\Jobs;
- //
+use Illuminate\Bus\Queueable;
+abstract class Job
+{
+ /*
+ |--------------------------------------------------------------------------
+ | 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 "onQueue" and "delay" queue helper methods.
+ |
+ */
+
+ use Queueable;
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -25,10 +25,6 @@
*/
public function register()
{
- $this->app->bind(
- 'Illuminate\Contracts\Auth\Registrar',
- 'AuthGrove\Services\Registrar'
- );
}
}
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
new file mode 100644
--- /dev/null
+++ b/app/Providers/AuthServiceProvider.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace AuthGrove\Providers;
+
+use Illuminate\Contracts\Auth\Access\Gate as GateContract;
+use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
+
+class AuthServiceProvider extends ServiceProvider {
+ /**
+ * The policy mappings for the application.
+ *
+ * @var array
+ */
+ protected $policies = [
+ 'AuthGrove\Model' => 'AuthGrove\Policies\ModelPolicy',
+ ];
+
+ /**
+ * Register any application authentication / authorization services.
+ *
+ * @param \Illuminate\Contracts\Auth\Access\Gate $gate
+ * @return void
+ */
+ public function boot(GateContract $gate) {
+ $this->registerPolicies($gate);
+ }
+}
diff --git a/app/Providers/BusServiceProvider.php b/app/Providers/BusServiceProvider.php
deleted file mode 100644
--- a/app/Providers/BusServiceProvider.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php namespace AuthGrove\Providers;
-
-use Illuminate\Bus\Dispatcher;
-use Illuminate\Support\ServiceProvider;
-
-class BusServiceProvider extends ServiceProvider {
-
- /**
- * Bootstrap any application services.
- *
- * @param \Illuminate\Bus\Dispatcher $dispatcher
- * @return void
- */
- public function boot(Dispatcher $dispatcher)
- {
- $dispatcher->mapUsing(function($command)
- {
- return Dispatcher::simpleMapping(
- $command, 'AuthGrove\Commands', 'AuthGrove\Handlers\Commands'
- );
- });
- }
-
- /**
- * Register any application services.
- *
- * @return void
- */
- public function register()
- {
- //
- }
-
-}
diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php
deleted file mode 100644
--- a/app/Providers/ConfigServiceProvider.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php namespace AuthGrove\Providers;
-
-use Illuminate\Support\ServiceProvider;
-
-class ConfigServiceProvider extends ServiceProvider {
-
- /**
- * Overwrite any vendor / package configuration.
- *
- * This service provider is intended to provide a convenient location for you
- * to overwrite any "vendor" or package configuration that you may want to
- * modify before the application handles the incoming request / command.
- *
- * @return void
- */
- public function register()
- {
- config([
- //
- ]);
- }
-
-}
diff --git a/app/Services/AuthenticatesAndRegistersUsers.php b/app/Services/AuthenticatesAndRegistersUsers.php
deleted file mode 100644
--- a/app/Services/AuthenticatesAndRegistersUsers.php
+++ /dev/null
@@ -1,140 +0,0 @@
-<?php namespace AuthGrove\Services;
-
-use Illuminate\Http\Request;
-use Illuminate\Contracts\Auth\Guard;
-use Illuminate\Contracts\Auth\Registrar;
-use Illuminate\Support\Facades\Lang as Lang;
-
-trait AuthenticatesAndRegistersUsers {
-
- /**
- * The Guard implementation.
- *
- * @var Guard
- */
- protected $auth;
-
- /**
- * The registrar implementation.
- *
- * @var Registrar
- */
- protected $registrar;
-
- /**
- * Show the application registration form.
- *
- * @return \Illuminate\Http\Response
- */
- public function getRegister()
- {
- return view('auth.register');
- }
-
- /**
- * Handle a registration request for the application.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function postRegister(Request $request)
- {
- $validator = $this->registrar->validator($request->all());
-
- if ($validator->fails())
- {
- $this->throwValidationException(
- $request, $validator
- );
- }
-
- $this->auth->login($this->registrar->create($request->all()));
-
- return redirect($this->redirectPath());
- }
-
- /**
- * Show the application login form.
- *
- * @return \Illuminate\Http\Response
- */
- public function getLogin()
- {
- return view('auth.login');
- }
-
- /**
- * Handle a login request to the application.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function postLogin(Request $request)
- {
- $this->validate($request, [
- 'username' => 'required',
- 'password' => 'required',
- ]);
-
- $credentials = $request->only('username', 'password');
-
- if ($this->auth->attempt($credentials, $request->has('remember')))
- {
- return redirect()->intended($this->redirectPath());
- }
-
- return redirect($this->loginPath())
- ->withInput($request->only('username', 'remember'))
- ->withErrors([
- 'username' => $this->getFailedLoginMessage(),
- ]);
- }
-
- /**
- * Get the failed login message.
- *
- * @return string
- */
- protected function getFailedLoginMessage()
- {
- return Lang::get('login.failedLogin');
- }
-
- /**
- * Log the user out of the application.
- *
- * @return \Illuminate\Http\Response
- */
- public function getLogout()
- {
- $this->auth->logout();
-
- return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
- }
-
- /**
- * Get the post register / login redirect path.
- *
- * @return string
- */
- public function redirectPath()
- {
- if (property_exists($this, 'redirectPath'))
- {
- return $this->redirectPath;
- }
-
- return property_exists($this, 'redirectTo') ? $this->redirectTo : '/';
- }
-
- /**
- * Get the path to the login route.
- *
- * @return string
- */
- public function loginPath()
- {
- return property_exists($this, 'loginPath') ? $this->loginPath : '/auth/login';
- }
-
-}
diff --git a/app/Services/Registrar.php b/app/Services/Registrar.php
--- a/app/Services/Registrar.php
+++ b/app/Services/Registrar.php
@@ -2,9 +2,11 @@
use AuthGrove\User;
use Validator;
-use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
-class Registrar implements RegistrarContract {
+/**
+ * Trait offering an implementation of Illuminate\Contracts\Auth\Registrar
+ */
+trait Registrar {
/**
* Get a validator for an incoming registration request.
diff --git a/app/Services/ResetsPasswords.php b/app/Services/ResetsPasswords.php
--- a/app/Services/ResetsPasswords.php
+++ b/app/Services/ResetsPasswords.php
@@ -1,30 +1,33 @@
-<?php namespace AuthGrove\Services;
+<?php
+namespace AuthGrove\Services;
+
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
-use Illuminate\Contracts\Auth\PasswordBroker;
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Illuminate\Mail\Message;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Password;
+use Illuminate\Foundation\Auth\RedirectsUsers;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
trait ResetsPasswords {
- // This trait assumes we include it in a class implementing var Guard $auth.
+ use RedirectsUsers;
- /**
- * The password broker implementation.
- *
- * @var PasswordBroker
- */
- protected $passwords;
+ ///
+ /// GET and POST routes
+ ///
- /**
- * Display the form to request a password reset link.
+ /**
+ * Display the password recover view.
*
- * @return Response
- */
- public function getRecover()
- {
- return view('auth.recover');
- }
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function getRecover(Request $request) {
+ return view('auth.recover');
+ }
/**
* Send a reset link to the given user.
@@ -32,33 +35,8 @@
* @param Request $request
* @return Response
*/
- public function postRecover(Request $request)
- {
- $this->validate($request, ['email' => 'required|email']);
-
- $response = $this->passwords->sendResetLink($request->only('email'), function($m)
- {
- $m->subject($this->getEmailSubject());
- });
-
- switch ($response)
- {
- case PasswordBroker::RESET_LINK_SENT:
- return redirect()->back()->with('status', trans($response));
-
- case PasswordBroker::INVALID_USER:
- return redirect()->back()->withErrors(['email' => trans($response)]);
- }
- }
-
- /**
- * Get the e-mail subject line to be used for the reset link email.
- *
- * @return string
- */
- protected function getEmailSubject()
- {
- return isset($this->subject) ? $this->subject : trans('emails.reset-password-subject');
+ public function postRecover(Request $request) {
+ return $this->sendResetLinkEmail($request);
}
/**
@@ -77,42 +55,254 @@
return view('auth.reset')->with('token', $token);
}
+ /**
+ * Reset the given user's password.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function postReset(Request $request) {
+ return $this->reset($request);
+ }
+
+ /**
+ * Get the response for after a successful password reset.
+ *
+ * @param string $response
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ protected function getResetSuccessResponse($response) {
+ return redirect($this->redirectPath())
+ ->with('status', trans($response));
+ }
+
+ /**
+ * Get the response for after a failing password reset.
+ *
+ * @param Request $request
+ * @param string $response
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ protected function getResetFailureResponse(Request $request, $response) {
+ return redirect()->back()
+ ->withInput($request->only('email'))
+ ->withErrors(['email' => trans($response)]);
+ }
+
+ ///
+ /// Controller helper utilities
+ ///
+
+ /**
+ * Get the name of the guest middleware.
+ *
+ * @return string
+ */
+ protected function guestMiddleware() {
+ $guard = $this->getGuard();
+
+ return $guard ? 'guest:' . $guard : 'guest';
+ }
+
+ /**
+ * Get the broker to be used during password reset.
+ *
+ * @return string|null
+ */
+ public function getBroker() {
+ return property_exists($this, 'broker') ? $this->broker : null;
+ }
+
+ /**
+ * Get the guard to be used during password reset.
+ *
+ * @return string|null
+ */
+ protected function getGuard() {
+ return property_exists($this, 'guard') ? $this->guard : null;
+ }
+
+ ///
+ /// Reset password e-mail helper methods
+ ///
+
+ /**
+ * Send a reset link to the given user.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function sendResetLinkEmail(Request $request) {
+ $this->validateSendResetLinkEmail($request);
+
+ $broker = $this->getBroker();
+
+ $response = Password::broker($broker)->sendResetLink(
+ $this->getSendResetLinkEmailCredentials($request),
+ $this->resetEmailBuilder()
+ );
+
+ switch ($response) {
+ case Password::RESET_LINK_SENT:
+ return $this->getSendResetLinkEmailSuccessResponse($response);
+ case Password::INVALID_USER:
+ default:
+ return $this->getSendResetLinkEmailFailureResponse($response);
+ }
+ }
+
+ /**
+ * Validate the request of sending reset link.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return void
+ */
+ protected function validateSendResetLinkEmail(Request $request) {
+ $this->validate($request, ['email' => 'required|email']);
+ }
+
+ /**
+ * Get the needed credentials for sending the reset link.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return array
+ */
+ protected function getSendResetLinkEmailCredentials(Request $request) {
+ return $request->only('email');
+ }
+
+ /**
+ * Get the Closure which is used to build the password reset email message.
+ *
+ * @return \Closure
+ */
+ protected function resetEmailBuilder() {
+ return function (Message $message) {
+ $message->subject($this->getEmailSubject());
+ };
+ }
+
/**
- * Reset the given user's password.
+ * Get the e-mail subject line to be used for the reset link email.
*
- * @param Request $request
- * @return Response
+ * @return string
*/
- public function postReset(Request $request)
+ protected function getEmailSubject()
{
- $this->validate($request, [
- 'token' => 'required',
- 'email' => 'required|email',
- 'password' => 'required|confirmed',
- ]);
+ return property_exists($this, 'subject') ? $this->subject : trans('emails.reset-password-subject');
+ }
- $credentials = $request->only(
- 'email', 'password', 'password_confirmation', 'token'
- );
+ /**
+ * Get the response for after the reset link has been successfully sent.
+ *
+ * @param string $response
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ protected function getSendResetLinkEmailSuccessResponse($response) {
+ return redirect()->back()->with('status', trans($response));
+ }
- $response = $this->passwords->reset($credentials, function($user, $password)
- {
- $user->password = bcrypt($password);
+ /**
+ * Get the response for after the reset link could not be sent.
+ *
+ * @param string $response
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ protected function getSendResetLinkEmailFailureResponse($response) {
+ return redirect()->back()->withErrors(['email' => trans($response)]);
+ }
- $user->save();
+ ///
+ /// Helper methods to handle password reset
+ ///
- $this->auth->login($user);
- });
+ /**
+ * Reset the given user's password.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Http\Response
+ */
+ public function reset(Request $request) {
+ $this->validate(
+ $request,
+ $this->getResetValidationRules(),
+ $this->getResetValidationMessages(),
+ $this->getResetValidationCustomAttributes()
+ );
- switch ($response)
- {
- case PasswordBroker::PASSWORD_RESET:
- return redirect($this->redirectPath());
+ $credentials = $this->getResetCredentials($request);
+
+ $broker = $this->getBroker();
+
+ $response = Password::broker($broker)->reset($credentials, function ($user, $password) {
+ $this->resetPassword($user, $password);
+ });
+
+ switch ($response) {
+ case Password::PASSWORD_RESET:
+ return $this->getResetSuccessResponse($response);
+ default:
+ return $this->getResetFailureResponse($request, $response);
+ }
+ }
+
+ /**
+ * Get the password reset validation rules.
+ *
+ * @return array
+ */
+ protected function getResetValidationRules() {
+ return [
+ 'token' => 'required',
+ 'email' => 'required|email',
+ 'password' => 'required|confirmed|min:8',
+ ];
+ }
+
+ /**
+ * Get the password reset validation messages.
+ *
+ * @return array
+ */
+ protected function getResetValidationMessages() {
+ return [];
+ }
+
+ /**
+ * Get the password reset validation custom attributes.
+ *
+ * @return array
+ */
+ protected function getResetValidationCustomAttributes() {
+ return [];
+ }
+
+ /**
+ * Get the password reset credentials from the request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return array
+ */
+ protected function getResetCredentials(Request $request) {
+ return $request->only(
+ 'email', 'password', 'password_confirmation', 'token'
+ );
+ }
+
+ /**
+ * Reset the given user's password.
+ *
+ * @param \Illuminate\Contracts\Auth\CanResetPassword $user
+ * @param string $password
+ * @return void
+ */
+ protected function resetPassword($user, $password) {
+ $user->forceFill([
+ 'password' => bcrypt($password),
+ 'remember_token' => Str::random(60),
+ ])->save();
+
+ Auth::guard($this->getGuard())->login($user);
+ }
- default:
- return redirect()->back()
- ->withInput($request->only('email'))
- ->withErrors(['email' => trans($response)]);
- }
- }
}
diff --git a/app/User.php b/app/User.php
--- a/app/User.php
+++ b/app/User.php
@@ -3,34 +3,39 @@
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
-use AuthGrove\Services\FindableByAttribute;
+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 {
+use AuthGrove\Services\FindableByAttribute;
- use Authenticatable, CanResetPassword, FindableByAttribute;
+class User extends Model implements AuthenticatableContract,
+ AuthorizableContract,
+ CanResetPasswordContract
+{
+ use Authenticatable, Authorizable, CanResetPassword, FindableByAttribute;
- /**
- * The database table used by the model.
- *
- * @var string
- */
- protected $table = 'users';
+ /**
+ * The database table used by the model.
+ *
+ * @var string
+ */
+ protected $table = 'users';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = ['username', 'fullname', 'email', 'password'];
+ /**
+ * The attributes that are mass assignable.
+ *
+ * @var array
+ */
+ protected $fillable = ['username', 'fullname', 'email', 'password'];
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = ['password', 'remember_token'];
+ /**
+ * The attributes excluded from the model's JSON form.
+ *
+ * @var array
+ */
+ protected $hidden = ['password', 'remember_token'];
/**
* Gets fillable but not hidden attributes, plus create/update time
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -6,7 +6,7 @@
"type": "project",
"require": {
"php": ">=5.5.9",
- "laravel/framework": "5.1.*",
+ "laravel/framework": "5.2.*",
"artisaninweb/laravel-enum": "1.0.*",
"keruald/globalfunctions": "~0.3"
},
@@ -14,7 +14,9 @@
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
- "phpspec/phpspec": "~2.1"
+ "phpspec/phpspec": "~2.1",
+ "symfony/dom-crawler": "~3.0",
+ "symfony/css-selector": "~3.0"
},
"autoload": {
"classmap": [
@@ -48,6 +50,6 @@
"config": {
"preferred-install": "dist"
},
- "minimum-stability": "dev",
+ "minimum-stability": "beta",
"prefer-stable": true
}
diff --git a/config/app.php b/config/app.php
--- a/config/app.php
+++ b/config/app.php
@@ -15,6 +15,19 @@
'debug' => env('APP_DEBUG', false),
+ /*
+ |--------------------------------------------------------------------------
+ | 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 URL
@@ -133,42 +146,40 @@
/*
* Laravel Framework Service Providers...
*/
- 'Illuminate\Foundation\Providers\ArtisanServiceProvider',
- 'Illuminate\Auth\AuthServiceProvider',
- 'Illuminate\Bus\BusServiceProvider',
- 'Illuminate\Cache\CacheServiceProvider',
- 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
- 'Illuminate\Routing\ControllerServiceProvider',
- 'Illuminate\Cookie\CookieServiceProvider',
- 'Illuminate\Database\DatabaseServiceProvider',
- 'Illuminate\Encryption\EncryptionServiceProvider',
- 'Illuminate\Filesystem\FilesystemServiceProvider',
- 'Illuminate\Foundation\Providers\FoundationServiceProvider',
- 'Illuminate\Hashing\HashServiceProvider',
- 'Illuminate\Mail\MailServiceProvider',
- 'Illuminate\Pagination\PaginationServiceProvider',
- 'Illuminate\Pipeline\PipelineServiceProvider',
- 'Illuminate\Queue\QueueServiceProvider',
- 'Illuminate\Redis\RedisServiceProvider',
- 'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
- 'Illuminate\Session\SessionServiceProvider',
- 'Illuminate\Translation\TranslationServiceProvider',
- 'Illuminate\Validation\ValidationServiceProvider',
- 'Illuminate\View\ViewServiceProvider',
+ Illuminate\Auth\AuthServiceProvider::class,
+ Illuminate\Broadcasting\BroadcastServiceProvider::class,
+ Illuminate\Bus\BusServiceProvider::class,
+ Illuminate\Cache\CacheServiceProvider::class,
+ Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
+ Illuminate\Cookie\CookieServiceProvider::class,
+ Illuminate\Database\DatabaseServiceProvider::class,
+ Illuminate\Encryption\EncryptionServiceProvider::class,
+ Illuminate\Filesystem\FilesystemServiceProvider::class,
+ Illuminate\Foundation\Providers\FoundationServiceProvider::class,
+ Illuminate\Hashing\HashServiceProvider::class,
+ Illuminate\Mail\MailServiceProvider::class,
+ Illuminate\Pagination\PaginationServiceProvider::class,
+ Illuminate\Pipeline\PipelineServiceProvider::class,
+ Illuminate\Queue\QueueServiceProvider::class,
+ Illuminate\Redis\RedisServiceProvider::class,
+ Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
+ Illuminate\Session\SessionServiceProvider::class,
+ Illuminate\Translation\TranslationServiceProvider::class,
+ Illuminate\Validation\ValidationServiceProvider::class,
+ Illuminate\View\ViewServiceProvider::class,
/*
* Third-party Service Providers...
*/
- 'Artisaninweb\Enum\EnumServiceProvider',
+ Artisaninweb\Enum\EnumServiceProvider::class,
/*
* Application Service Providers...
*/
- 'AuthGrove\Providers\AppServiceProvider',
- 'AuthGrove\Providers\BusServiceProvider',
- 'AuthGrove\Providers\ConfigServiceProvider',
- 'AuthGrove\Providers\EventServiceProvider',
- 'AuthGrove\Providers\RouteServiceProvider',
+ AuthGrove\Providers\AppServiceProvider::class,
+ AuthGrove\Providers\AuthServiceProvider::class,
+ AuthGrove\Providers\EventServiceProvider::class,
+ AuthGrove\Providers\RouteServiceProvider::class,
],
@@ -184,40 +195,47 @@
*/
'aliases' => [
-
- 'App' => 'Illuminate\Support\Facades\App',
- 'Artisan' => 'Illuminate\Support\Facades\Artisan',
- 'Auth' => 'Illuminate\Support\Facades\Auth',
- 'Blade' => 'Illuminate\Support\Facades\Blade',
- 'Bus' => 'Illuminate\Support\Facades\Bus',
- 'Cache' => 'Illuminate\Support\Facades\Cache',
- 'Config' => 'Illuminate\Support\Facades\Config',
- 'Cookie' => 'Illuminate\Support\Facades\Cookie',
- 'Crypt' => 'Illuminate\Support\Facades\Crypt',
- 'DB' => 'Illuminate\Support\Facades\DB',
- 'Eloquent' => 'Illuminate\Database\Eloquent\Model',
- 'EnumMap' => 'Artisaninweb\Enum\Facades\EnumFacade',
- 'Event' => 'Illuminate\Support\Facades\Event',
- 'File' => 'Illuminate\Support\Facades\File',
- 'Hash' => 'Illuminate\Support\Facades\Hash',
- 'Input' => 'Illuminate\Support\Facades\Input',
- 'Inspiring' => 'Illuminate\Foundation\Inspiring',
- 'Lang' => 'Illuminate\Support\Facades\Lang',
- 'Log' => 'Illuminate\Support\Facades\Log',
- 'Mail' => 'Illuminate\Support\Facades\Mail',
- 'Password' => 'Illuminate\Support\Facades\Password',
- 'Queue' => 'Illuminate\Support\Facades\Queue',
- 'Redirect' => 'Illuminate\Support\Facades\Redirect',
- 'Redis' => 'Illuminate\Support\Facades\Redis',
- 'Request' => 'Illuminate\Support\Facades\Request',
- 'Response' => 'Illuminate\Support\Facades\Response',
- 'Route' => 'Illuminate\Support\Facades\Route',
- 'Schema' => 'Illuminate\Support\Facades\Schema',
- 'Session' => 'Illuminate\Support\Facades\Session',
- 'Storage' => 'Illuminate\Support\Facades\Storage',
- 'URL' => 'Illuminate\Support\Facades\URL',
- 'Validator' => 'Illuminate\Support\Facades\Validator',
- 'View' => 'Illuminate\Support\Facades\View',
+ /*
+ * Laravel Framework aliases...
+ */
+ 'App' => Illuminate\Support\Facades\App::class,
+ '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,
+ 'Crypt' => Illuminate\Support\Facades\Crypt::class,
+ 'DB' => Illuminate\Support\Facades\DB::class,
+ '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,
+ 'Lang' => Illuminate\Support\Facades\Lang::class,
+ 'Log' => Illuminate\Support\Facades\Log::class,
+ 'Mail' => Illuminate\Support\Facades\Mail::class,
+ 'Password' => Illuminate\Support\Facades\Password::class,
+ 'Queue' => Illuminate\Support\Facades\Queue::class,
+ 'Redirect' => Illuminate\Support\Facades\Redirect::class,
+ 'Redis' => Illuminate\Support\Facades\Redis::class,
+ 'Request' => Illuminate\Support\Facades\Request::class,
+ 'Response' => Illuminate\Support\Facades\Response::class,
+ 'Route' => Illuminate\Support\Facades\Route::class,
+ 'Schema' => Illuminate\Support\Facades\Schema::class,
+ 'Session' => Illuminate\Support\Facades\Session::class,
+ 'Storage' => Illuminate\Support\Facades\Storage::class,
+ 'URL' => Illuminate\Support\Facades\URL::class,
+ 'Validator' => Illuminate\Support\Facades\Validator::class,
+ 'View' => Illuminate\Support\Facades\View::class,
+
+ /*
+ * App aliases...
+ */
+ 'EnumMap' => Artisaninweb\Enum\Facades\EnumFacade::class,
],
diff --git a/config/auth.php b/config/auth.php
--- a/config/auth.php
+++ b/config/auth.php
@@ -2,66 +2,106 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Default Authentication Driver
- |--------------------------------------------------------------------------
- |
- | 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.
- |
- | Supported: "database", "eloquent"
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Defaults
+ |--------------------------------------------------------------------------
+ |
+ | 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.
+ |
+ */
- 'driver' => 'eloquent',
+ 'defaults' => [
+ 'guard' => 'web',
+ 'passwords' => '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.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | 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"
+ |
+ */
- 'model' => 'AuthGrove\User',
+ 'guards' => [
+ 'web' => [
+ 'driver' => 'session',
+ 'provider' => 'users',
+ ],
- /*
- |--------------------------------------------------------------------------
- | 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.
- |
- */
+ 'api' => [
+ 'driver' => 'token',
+ 'provider' => 'users',
+ ],
+ ],
- 'table' => '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"
+ |
+ */
- /*
- |--------------------------------------------------------------------------
- | Password Reset Settings
- |--------------------------------------------------------------------------
- |
- | 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
- | table that maintains all of the reset tokens for your application.
- |
- | 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.
- |
- */
+ 'providers' => [
+ 'users' => [
+ 'driver' => 'eloquent',
+ 'model' => AuthGrove\User::class,
+ ],
- 'password' => [
- 'email' => 'emails.password',
- 'table' => 'password_resets',
- 'expire' => 60,
- ],
+ // 'users' => [
+ // 'driver' => 'database',
+ // 'table' => 'users',
+ // ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Resetting Passwords
+ |--------------------------------------------------------------------------
+ |
+ | Here you may set the options for resetting passwords including the view
+ | 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.
+ |
+ */
+
+ 'passwords' => [
+ 'users' => [
+ 'provider' => 'users',
+ 'email' => 'emails.password',
+ 'table' => 'password_resets',
+ 'expire' => 60,
+ ],
+ ],
];
diff --git a/config/compile.php b/config/compile.php
--- a/config/compile.php
+++ b/config/compile.php
@@ -16,8 +16,7 @@
'files' => [
realpath(__DIR__.'/../app/Providers/AppServiceProvider.php'),
- realpath(__DIR__.'/../app/Providers/BusServiceProvider.php'),
- realpath(__DIR__.'/../app/Providers/ConfigServiceProvider.php'),
+ realpath(__DIR__.'/../app/Providers/AuthServiceProvider.php'),
realpath(__DIR__.'/../app/Providers/EventServiceProvider.php'),
realpath(__DIR__.'/../app/Providers/RouteServiceProvider.php'),
diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php
--- a/database/seeds/DatabaseSeeder.php
+++ b/database/seeds/DatabaseSeeder.php
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Seeder;
-use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder {
@@ -12,8 +11,6 @@
*/
public function run()
{
- Model::unguard();
-
// $this->call('UserTableSeeder');
}
diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php
new file mode 100644
--- /dev/null
+++ b/resources/lang/en/auth.php
@@ -0,0 +1,19 @@
+<?php
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are used during authentication for various
+ | messages that we need to display to the user. You are free to modify
+ | these language lines according to your application's requirements.
+ |
+ */
+
+ 'failed' => 'These credentials do not match our records.',
+ 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
+
+];
diff --git a/resources/lang/en/login.php b/resources/lang/en/login.php
--- a/resources/lang/en/login.php
+++ b/resources/lang/en/login.php
@@ -20,7 +20,7 @@
"passwordRecovery" => "Password recovery options",
"registerAccount" => "Register an account", //link
"blankAvatarAlt" => "A door, as a blank avatar",
-
+
//Register form
"usernamePlaceholder" => "Username. Will be used as login.",
"fullnamePlaceholder" => "Full name. For example, your real name.",
@@ -41,6 +41,4 @@
"resetPassword" => "New password",
"resetButton" => "Reset password",
- //Error messages
- "failedLogin" => "These credentials do not match our records.",
];
diff --git a/resources/lang/fr/auth.php b/resources/lang/fr/auth.php
new file mode 100644
--- /dev/null
+++ b/resources/lang/fr/auth.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * French translation by:
+ * - Michaël Colignon (philectro)
+ * - Sébastien Santoro (dereckson)
+ */
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are used during authentication for various
+ | messages that we need to display to the user. You are free to modify
+ | these language lines according to your application's requirements.
+ |
+ */
+
+ 'failed' => "Le login ou mot de passe est incorrect.",
+ 'throttle' => "Pour protéger votre compte, un délai de temporisation est en place : vous pourrez réessayer dans :seconds secondes.",
+
+];
diff --git a/resources/lang/fr/login.php b/resources/lang/fr/login.php
--- a/resources/lang/fr/login.php
+++ b/resources/lang/fr/login.php
@@ -26,6 +26,4 @@
"registerAccount" => "Créer un compte",
"blankAvatarAlt" => "Une porte, comme avatar par défaut.",
- // Error messages
- "failedLogin" => "Le login ou mot de passe est incorrect.",
];

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 08:36 (21 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2248990
Default Alt Text
D412.diff (53 KB)

Event Timeline