I've created my own routes to login:
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
Route::get('/registrar', [
'as' => 'clubRegistrar',
'uses' => 'Auth\AuthController@getRegister'
]);
Route::post('/registrar', [
'as' => 'clubPostRegistrar',
'uses' => 'Auth\AuthController@postRegister'
]);
Route::get('/ingresar', [
'as' => 'clubIngresar',
'uses' => 'Auth\AuthController@getLogin'
]);
Route::post('/ingresar', [
'as' => 'clubPostIngresar',
'uses' => 'Auth\AuthController@postLogin'
]);
Route::get('/salir', [
'as' => 'clubSalir',
'uses' => 'Auth\AuthController@getLogout'
]);
There's only something missing, Password reset.
My problem right now is with the login routes, the get method is ok, it works, but the post method doesn't work properly, it authenticates the user, but it doesn't redirects to another route or path... Something curious is that it works well with the default view, but if i use my own view, it doesn't...
Here's my AuthController
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers;
private $loginPath = '/ingresar';
private $redirectTo = '/reservacion';
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
public function getRegister()
{
return view('Club.auth.register');
}
public function getLogin()
{
return view('Club.auth.login');
}
public function postLogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required',
]);
$inputs = $request->only('email', 'password');
$credentials = array_merge($inputs, ['type' => 1]);
if ($this->auth->attempt($credentials, $request->has('remember'))) {
return redirect()->intended($this->redirectPath());
}
return redirect($this->loginPath())
->withInput($request->only('email', 'remember'))
->withErrors([
'email' => $this->getFailedLoginMessage(),
]);
}
}
And here's my custom view:
<section class = "store-checkout" >
<div class = "container wow fadeInDown" >
<div class = "row" >
<div class = "col-md-12" >
<div class = "container" >
<div class = "row" >
<div class = "col-md-6 col-md-offset-3 wow fadeInDown" >
<div class = "contact-form-contaienr" >
<div class = "section-title" >
<h1 ><span >Inicia Sesion</span ></h1 >
</div >
{!! Form::open(['route' => 'clubPostIngresar', 'action' => 'clubPostIngresar',
'method' => 'post', 'id' => 'contact-form', 'role' => 'form' ]) !!}
{!! Form::token() !!}
{!! Form::email('email', old('email'), ['autocomplete' => 'off', 'placeholder' => 'E-Mail*','required']) !!}
{!! Form::password('password', ['placeholder' => 'Contrasena']) !!}
{!! Form::submit('Ingresar!',[]) !!}
{!! Form::close() !!}
<div id = "form-messages" >
@if (count($errors) > 0)
<strong >Whoops!</strong > Hubieron unos problemas con tus datos.<br ><br >
<ul >
@foreach ($errors->all() as $error)
<li >{{ $error }}</li >
@endforeach
</ul >
@endif
</div >
</div >
<!-- /contact-form-container -->
</div >
<!-- /col-md-6 -->
</div >
<!-- /row -->
</div >
<!-- /container -->
</div >
<!-- /col-md-12 -->
</div >
<!-- /row -->
</div >
<!-- /container -->
</section >
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ELOCdi
via IFTTT
Aucun commentaire:
Enregistrer un commentaire