Commit e0c102b7 authored by Nicolas Widart's avatar Nicolas Widart

Updating laravel

parent 79f71c4c
File mode changed from 100644 to 100755
<?php namespace App\Http\Controllers\Auth;
use Illuminate\Routing\Controller;
use Illuminate\Contracts\Auth\Guard;
use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\RegisterRequest;
/**
* @Middleware("guest", except={"logout"})
*/
class AuthController extends Controller {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new authentication controller instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Show the application registration form.
*
* @Get("auth/register")
*
* @return Response
*/
public function showRegistrationForm()
{
return view('auth.register');
}
/**
* Handle a registration request for the application.
*
* @Post("auth/register")
*
* @param RegisterRequest $request
* @return Response
*/
public function register(RegisterRequest $request)
{
// Registration form is valid, create user...
$this->auth->login($user);
return redirect('/');
}
/**
* Show the application login form.
*
* @Get("auth/login")
*
* @return Response
*/
public function showLoginForm()
{
return view('auth.login');
}
/**
* Handle a login request to the application.
*
* @Post("auth/login")
*
* @param LoginRequest $request
* @return Response
*/
public function login(LoginRequest $request)
{
if ($this->auth->attempt($request->only('email', 'password')))
{
return redirect('/');
}
return redirect('/auth/login')->withErrors([
'email' => 'These credentials do not match our records.',
]);
}
/**
* Log the user out of the application.
*
* @Get("auth/logout")
*
* @return Response
*/
public function logout()
{
$this->auth->logout();
return redirect('/');
}
}
<?php namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Contracts\Auth\PasswordBroker;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* @Middleware("guest")
*/
class PasswordController extends Controller {
/**
* The password broker implementation.
*
* @var PasswordBroker
*/
protected $passwords;
/**
* Create a new password controller instance.
*
* @param PasswordBroker $passwords
* @return void
*/
public function __construct(PasswordBroker $passwords)
{
$this->passwords = $passwords;
}
/**
* Display the form to request a password reset link.
*
* @Get("password/email")
*
* @return Response
*/
public function showResetRequestForm()
{
return view('password.email');
}
/**
* Send a reset link to the given user.
*
* @Post("password/email")
*
* @param Request $request
* @return Response
*/
public function sendResetLink(Request $request)
{
switch ($response = $this->passwords->sendResetLink($request->only('email')))
{
case PasswordBroker::INVALID_USER:
return redirect()->back()->with('error', trans($response));
case PasswordBroker::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
}
}
/**
* Display the password reset view for the given token.
*
* @Get("password/reset")
*
* @param string $token
* @return Response
*/
public function showResetForm($token = null)
{
if (is_null($token))
{
throw new NotFoundHttpException;
}
return view('password.reset')->with('token', $token);
}
/**
* Reset the given user's password.
*
* @Post("password/reset")
*
* @param Request $request
* @return Response
*/
public function resetPassword(Request $request)
{
$credentials = $request->only(
'email', 'password', 'password_confirmation', 'token'
);
$response = $this->passwords->reset($credentials, function($user, $password)
{
$user->password = bcrypt($password);
$user->save();
});
switch ($response)
{
case PasswordBroker::INVALID_PASSWORD:
case PasswordBroker::INVALID_TOKEN:
case PasswordBroker::INVALID_USER:
return redirect()->back()->with('error', trans($response));
case PasswordBroker::PASSWORD_RESET:
return redirect()->to('/');
}
}
}
<?php namespace App\Http\Controllers;
class HomeController {
use Illuminate\Routing\Controller;
class HomeController extends Controller {
/*
|--------------------------------------------------------------------------
| Default Home Controller
| Home Controller
|--------------------------------------------------------------------------
|
| You may wish to use controllers instead of, or in addition to, Closure
| based routes. That's great! Here is an example controller method to
| get you started. To route to this controller, just add the route:
|
| $router->get('/', 'HomeController@index');
| Controller methods are called when a request enters the application
| with their assigned URI. The URI a method responds to may be set
| via simple annotations. Here is an example to get you started!
|
*/
/**
* @Get("/", as="home")
* @Get("/")
*/
public function index()
{
......
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Routing\Route;
use Illuminate\Contracts\Auth\Authenticator;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Routing\ResponseFactory;
class AuthMiddleware implements Middleware {
/**
* The authenticator implementation.
* The Guard implementation.
*
* @var Authenticator
* @var Guard
*/
protected $auth;
......@@ -25,11 +24,11 @@ class AuthMiddleware implements Middleware {
/**
* Create a new filter instance.
*
* @param Authenticator $auth
* @param Guard $auth
* @param ResponseFactory $response
* @return void
*/
public function __construct(Authenticator $auth,
public function __construct(Guard $auth,
ResponseFactory $response)
{
$this->auth = $auth;
......
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Auth\Authenticator;
class BasicAuthMiddleware implements Middleware {
/**
* The authenticator implementation.
* The Guard implementation.
*
* @var Authenticator
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Authenticator $auth
* @param Guard $auth
* @return void
*/
public function __construct(Authenticator $auth)
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
......
......@@ -12,6 +12,8 @@ class CsrfMiddleware implements Middleware {
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws TokenMismatchException
*/
public function handle($request, Closure $next)
{
......
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\RedirectResponse;
use Illuminate\Contracts\Auth\Authenticator;
use Illuminate\Contracts\Routing\Middleware;
class GuestMiddleware implements Middleware {
/**
* The authenticator implementation.
* The Guard implementation.
*
* @var Authenticator
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Authenticator $auth
* @param Guard $auth
* @return void
*/
public function __construct(Authenticator $auth)
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
......
......@@ -5,7 +5,7 @@ use Illuminate\Http\Response;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Foundation\Application;
class MaintenanceMiddleware {
class MaintenanceMiddleware implements Middleware {
/**
* The application implementation.
......
File mode changed from 100644 to 100755
<?php namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class LoginRequest extends FormRequest {
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required', 'password' => 'required',
];
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
}
<?php namespace App\Http\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class RegisterRequest extends FormRequest {
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email|unique:users',
'password' => 'required|confirmed|min:8',
];
}
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
}
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
$router->get('/', 'HomeController@index');
......@@ -29,6 +29,8 @@ class AppServiceProvider extends ServiceProvider {
'Illuminate\Cookie\Middleware\Queue',
'Illuminate\Session\Middleware\Reader',
'Illuminate\Session\Middleware\Writer',
'Illuminate\View\Middleware\ErrorBinder',
'App\Http\Middleware\CsrfMiddleware',
];
/**
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -15,4 +15,13 @@ class EventServiceProvider extends ServiceProvider {
],
];
/**
* The classes to scan for event annotations.
*
* @var array
*/
protected $scan = [
//
];
}
File mode changed from 100644 to 100755
<?php namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider {
/**
* The root namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $rootUrlNamespace = 'App\Http\Controllers';
/**
* The controllers to scan for route annotations.
*
* @var array
*/
protected $scan = [
'App\Http\Controllers\HomeController',
'App\Http\Controllers\Auth\AuthController',
'App\Http\Controllers\Auth\PasswordController',
];
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @param Router $router
* @param UrlGenerator $url
* @return void
*/
public function before(Router $router, UrlGenerator $url)
public function before(Router $router)
{
$url->setRootControllerNamespace('App\Http\Controllers');
//
}
/**
......@@ -25,18 +41,9 @@ class RouteServiceProvider extends ServiceProvider {
*
* @return void
*/
public function map()
public function map(Router $router)
{
// Once the application has booted, we will include the default routes
// file. This "namespace" helper will load the routes file within a
// route group which automatically sets the controller namespace.
$this->app->booted(function()
{
$this->namespaced('App\Http\Controllers', function(Router $router)
{
require app_path().'/Http/routes.php';
});
});
// require app_path('Http/routes.php');
}
}
......@@ -2,13 +2,13 @@
use Illuminate\Auth\UserTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Contracts\Auth\User as UserContract;
use Illuminate\Contracts\Auth\Remindable as RemindableContract;
use Illuminate\Auth\Passwords\CanResetPasswordTrait;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements UserContract, RemindableContract {
class User extends Model implements UserContract, CanResetPasswordContract {
use UserTrait, RemindableTrait;
use UserTrait, CanResetPasswordTrait;
/**
* The database table used by the model.
......
This diff is collapsed.
......@@ -105,15 +105,6 @@ return [
'App\Providers\LogServiceProvider',
'App\Providers\RouteServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Pingpong\Modules\ModulesServiceProvider',
'Cartalyst\Sentinel\Laravel\SentinelServiceProvider',
'Laracasts\Commander\CommanderServiceProvider',
'Laracasts\Flash\FlashServiceProvider',
'Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider',
'Modules\Core\Providers\CoreServiceProvider',
/*
* Laravel Framework Service Providers...
*/
......@@ -121,6 +112,7 @@ return [
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
......@@ -132,7 +124,7 @@ return [
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
......@@ -195,15 +187,7 @@ return [
'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
'Form' => 'Illuminate\Html\FormFacade',
/* Packages */
'Form' => 'Illuminate\Html\FormFacade',
'Module' => 'Pingpong\Modules\Facades\Module',
'Activation' => 'Cartalyst\Sentinel\Laravel\Facades\Activation',
'Reminder' => 'Cartalyst\Sentinel\Laravel\Facades\Reminder',
'Sentinel' => 'Cartalyst\Sentinel\Laravel\Facades\Sentinel',
'Flash' => 'Laracasts\Flash\Flash',
'LaravelLocalization' => 'Mcamara\LaravelLocalization\Facades\LaravelLocalization',
],
];
......@@ -45,22 +45,22 @@ return [
/*
|--------------------------------------------------------------------------
| Password Reminder Settings
| Password Reset Settings
|--------------------------------------------------------------------------
|
| Here you may set the settings for password reminders, including a view
| that should be used as your password reminder e-mail. You will also
| be able to set the name of the table that holds the reset tokens.
| 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 reminder should be
| 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.
|
*/
'reminder' => [
'email' => 'emails.auth.reminder',
'table' => 'password_reminders',
'password' => [
'email' => 'emails.auth.password',
'table' => 'password_resets',
'expire' => 60,
],
......
......@@ -28,17 +28,4 @@ return [
'compiled' => storage_path().'/framework/views',
/*
|--------------------------------------------------------------------------
| Pagination View
|--------------------------------------------------------------------------
|
| This view will be used to render the pagination link output, and can
| be easily customized here to show any view you like. A clean view
| compatible with Twitter's Bootstrap is given to you by default.
|
*/
'pagination' => 'pagination::slider-3',
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment