Middlewares Laravel

0

I am new to laravel and I have a redirection problem. I get this message on the page:

  

ERR_TOO_MANY_REDIRECTS

This happens when I put the validation of required, if I remove it if it works, could you tell me why?:

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Validator;

class ValidateFields
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $validate =Validator::make($request->all(),[
            "email"=>"email",
             "password"=>"required"
            ]
        );

        if ($validate->fails()) {
          return redirect("login")->withErrors($validate);
        }

        return $next($request);
    }
}

?>
    
asked by oscar leandro viera pereira 24.03.2017 в 18:30
source

1 answer

0

Although it seems that it is already solved, why do not you use the Laravel 5 authentication scaffold.

php composer make:auth

With that you will have everything you need, login, registration, forgot password and its corresponding validations.

    
answered by 26.03.2017 в 19:43