Greetings everyone, I have a problem when I make my custom Auth Controller in L5.1 my code is:
CustomAuth.php
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Request;
class CustomAuth extends Controller {
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|string
*/
public function postLogin()
{
$credentials = [
$email = Request::input('correo'),
$pass = \Hash::make(Request::input('contra'))
];
$email = Request::input('correo');
$pass = \Hash::make(Request::input('contra'));
if(Auth::attempt(['email'=>$email, 'password'=>$pass])){
return "Hello World";
} else {
return "Hello Hell";
}
}
}
I define my routes:
Route::post('auth', 'CustomAuth@postLogin');
and my view is:
@extends('utils.others.allbody')
@section('bread')
<b>Login</b>
@endsection
@extends('utils.others.navigation')
@section('content')
<div style="margin-top:5%" class="container">
<div class="row">
<div class="col xs-6 col s6 card small">
<div class="">
{!! Form::open(['url'=>'auth', 'method'=>'POST', 'class'=>'input-field']) !!}
<div class="input-field col s12">
<i class="mdi-communication-email prefix"></i>
{!! Form::label('email', 'Correo Electrónico:', array('class'=>'col-md-4 control-label')) !!}
{!! Form::text('correo', null, array('class'=>'validate')) !!}
</div>
<div class="input-field col s12">
<i class="mdi-content-text-format prefix"></i>
{!! Form::label('password', 'Contraseña:', array('class'=>'col-md-4 control-label')) !!}
{!! Form::password('contra', null, array('class'=>'validate')) !!}
</div>
<div class="input-field col s6 offset-l1">
<button class="waves-effect waves-light btn"><i class="mdi-content-send right"></i>Conectarse</button>
</div>
<div class="input-field col s6 offset-l1">
<p>
<input type="checkbox" id="test6" class="filled-in" />
<label for="test6">Recuerdame</label>
</p>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
@endsection
and always when I try authenticate in my Login send me "Hello Hell" XD!, thanks and have a nice day and sorry for my bad english.
I think you need to pass the plain password and not the hashed one to attempt method.
osiux said:
I think you need to pass the plain password and not the hashed one to attempt method.
Ok let me try :) and thanks for you response :D
yonkishum said:
osiux said:
I think you need to pass the plain password and not the hashed one to attempt method.
Ok let me try :) and thanks for you response :D
It's work :D! YAY! Thanks oisux
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community